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.
I do undestand the code, I just don't understand why. I bet custom sort of an array wont't be more efficient than the built-in sort in Arrays. What's more, there's no need to store all sums in the array, the max value can be stored in one variable and re-set if counted sum exceeds its value.
(My solution did not pass the 3rd test (with negative numbers in input array) for the first time, because I had initialized int max = 0, so I changed it to Integer max = null and checked it when used in comparison.)
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 →
I do undestand the code, I just don't understand why. I bet custom sort of an array wont't be more efficient than the built-in sort in Arrays. What's more, there's no need to store all sums in the array, the max value can be stored in one variable and re-set if counted sum exceeds its value. (My solution did not pass the 3rd test (with negative numbers in input array) for the first time, because I had initialized int max = 0, so I changed it to Integer max = null and checked it when used in comparison.)