Education + Jobs Hiring Website - 2025
0 like 0 dislike
3,388 views
in Online Assessments by Expert (145,160 points) | 3,388 views

1 Answer

0 like 0 dislike
You are given a 2d matrix A of m rows and n colums and you have to generate a matrix B of same dimension but the elements must be a summation of all the previous elements upto now.


For example if A=[{1,2,3},{4,5,6}],
then B =[{1,3,6},{5,12,21}]
Explanation: A(0,0)=B(0,0)
B(0,1)=A(0,0)+A(0,1)
B(0,2)=A(0,0)+A(0,1)+A(0,2)
B(1,0)=A(0,0)+A(1,0)
B(1,1)=A(0,0)+A(0,1)+A(1,0)+A(1,1)
B(1,2)=A(0,0)+A(0,1)+A(0,2)+A(1,0)+A(1,1)+A(1,2)
by Expert (145,160 points)