plz give the complete code of sum of submatrix with time complexity O6 and provide us the more detailed video on this as i am not able through this video
2D array problem
Approach one
here you have to first find cordinate of all submatrix and then add one by one
int SumofAllSubmatrix1(int **arr,int n){
int Total_sum=0;
for(int ti=0;ti<n;ti++){
for(int tj=0;tj<n;tj++){
//now we have top left cordinate
for(int bi=ti;bi<n;bi++){
for(int bj=tj;bj<n;bj++){
// now we have bottom right cordinate as well
// cout<<ti<<" "<<tj<<" "<<bi<<" "<<bj<<"\t\t";
// calculate sum of given submatrix
int sum=0;
for(int i=ti;i<=bi;i++){
for(int j=tj;j<=bj;j++){
sum+=arr[i][j];
}
}
Total_sum+=sum;
}
}
}
}
cout<<Total_sum<<endl;
}
i hope this help
if you have more doubts regarding this feel free to ask
if your doubt is resolved mark it as resolved from your doubt section inside your course