You are viewing a single comment's thread. Return to all comments →
what about the custom input:
1 5 -100
wouldn't the output be 0? But the max would be -100 since all elements would be -100.
There's a constraint: 0 <= k <= 10^9
In your case of negative k, the minimum value can be obtained by the similar approach. Imagine a valley rather than a mountain.