You are viewing a single comment's thread. Return to all comments →
I found out the problem and I had a really similar code like yours. The culprit is the Math.abs call. Try your code with this input:
Math.abs
(n=2, k = 6) [2, 4] 2 6 2 4
The solution is zero, but it outputs one because Math.abs gets in the way
Seems like cookies are disabled on this browser, please enable them to open this website
Pairs
You are viewing a single comment's thread. Return to all comments →
I found out the problem and I had a really similar code like yours. The culprit is the
Math.abs
call. Try your code with this input:The solution is zero, but it outputs one because
Math.abs
gets in the way