What if adding negative numbers as follow-up?


  • 0
    J

    The problem here gave us non-negative restriction, so we can easily grab the range for final answer is [max,sum] ,where max is the largest single value, sum is the total sum of whole array. Then we can apply binary search. But what if interviewer asked you to handle negative numbers?


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.