-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca7dfff
commit 9132407
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
...ENT & INTERNSHIP EXAM QUESTIONS/RAZORPAY/Find Original 2D array from prefix sum 2D array.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
int mat[10][10]; | ||
|
||
void fun(int r, int c) | ||
{ | ||
int ans[r][c]; | ||
|
||
ans[0][0]=mat[0][0]; | ||
|
||
for(int j=1;j<c;j++) | ||
ans[0][j]=mat[0][j]-mat[0][j-1]; | ||
|
||
for(int i=1;i<r;i++) | ||
ans[i][0]=mat[i][0]-mat[i-1][0]; | ||
|
||
for(int i=1;i<r;i++) | ||
{ | ||
for(int j=1;j<c;j++) | ||
{ | ||
ans[i][j]= mat[i][j]-mat[i-1][j]-mat[i][j-1]+mat[i-1][j-1]; | ||
} | ||
} | ||
|
||
for(int i=0;i<r;i++) | ||
{ | ||
for(int j=0;j<c;j++) | ||
{ | ||
cout<<ans[i][j]<<" "; | ||
} | ||
|
||
cout<<endl; | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|