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.
Simply "skipping" won't quite make this work. In this exercise each integer was in the inclusive range of [1, 10^9] so setting biggest would have sufficed as well.
In more general terms, if we had to assume the elements in the arrays are integer we have numbers ranging between [-2^31, 2^31 - 1] or in other words [Integer.MIN_VALUE, Integer.MAX_VALUE].
If you would simply "skip" this line, let's say you would set biggest to zero then passing your function the array: [-1,-3,-1,-5] would yield in 0 being the biggest, even though the number doesn't even appear in the array.
Mini-Max Sum
You are viewing a single comment's thread. Return to all comments →
Simply "skipping" won't quite make this work. In this exercise each integer was in the inclusive range of
[1, 10^9]
so settingbiggest
would have sufficed as well.In more general terms, if we had to assume the elements in the arrays are integer we have numbers ranging between
[-2^31, 2^31 - 1]
or in other words[Integer.MIN_VALUE, Integer.MAX_VALUE]
.If you would simply "skip" this line, let's say you would set
biggest
to zero then passing your function the array:[-1,-3,-1,-5]
would yield in 0 being the biggest, even though the number doesn't even appear in the array.