You are viewing a single comment's thread. Return to all comments →
c++
int hourglassSum(vector<vector<int>> arr) { vector<int>vek; int now =0; for (int i=2;i<arr.size();i++) { for (int j=2;j<arr.size();j++) { now = arr.at(i-2).at(j-2) + arr.at(i-2).at(j-1) + arr.at(i-2).at(j)+ arr.at(i-1).at(j-1) + arr.at(i).at(j-2) + arr.at(i).at(j-1) + arr.at(i).at(j); vek.push_back(now); } } vector<int>::iterator result = max_element(vek.begin(),vek.end()); return *result; }
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
2D Array - DS
You are viewing a single comment's thread. Return to all comments →
c++