Pairwise - false solution!?

It’s just a general question: shouldn’t the return of pairwise([0, 0, 0, 0, 1, 1], 1) be 9 since the indices of 1 are 4 and 5 so the smallest sum is 9!?

1 Like

Thanks, @rmdawson71 for clarification. Very helpful!

I don’t really follow your explanation. In the example you gave, you have two sums of indices that use the same numeric elements:

0 + 4 = 4.
1 + 5 = 6.

The instructions state “return the smallest sum of indices.” The smallest sum of indices is 4, so the answer to that example should be 4, not 10.

But it doesn’t seem to apply to the pairwise([1, 1, 1], 2) output.

arr[0] + arr[1] = 2

arr[1] + arr[2] = 2

0 + 1 = 1
1 + 2 = 3
3 + 1 = 4

I think I get it now. It’s not the element’s value that cannot be repeated, but the element itself.
Thanks

1 Like

Thank you, was wondering the same thing, thanks for explanation.