We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Good solution, but you don't need to keep track of all sums; you just need to keep track of the largest. If you set a "maxSum" variable, and only update it when currrSum > maxSum, you can eliminate the need for sorting ( which takes time ) as well as the sum array of size 16 ( which takes up space/memory ). (The variable h becomes unnecessary, too).
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 11: 2D Arrays
You are viewing a single comment's thread. Return to all comments →
Good solution, but you don't need to keep track of all sums; you just need to keep track of the largest. If you set a "maxSum" variable, and only update it when currrSum > maxSum, you can eliminate the need for sorting ( which takes time ) as well as the sum array of size 16 ( which takes up space/memory ). (The variable h becomes unnecessary, too).