Click here to see the full article post
Why isn't the first solution O((2N)^K instead of O(n^2k)? Seems like you loop through the array twice, but its not nested, so that would be 2N, and you do that K times.
I think we still need to make the moves variable long to avoid possible overflow .. consider this test case: [1, 5 ,2147483647] .
How to really understand this? "adding 1 to all the elements except one is equivalent to decrementing 1 from a single element,"
@Ltdan I am having the same thought with you! Could someone please explain its correctness? Thanks!
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.