Ad
  • Custom User Avatar

    In the first case, the pairs of indices are 0,4 and 1,5, summing to 10.

    In the second case, the pairs are 0,2 and 1,3, summing to 6.

    In both cases, use both 1s once ( "element .. can only be counted in one Pair" ), and use the 0s at indices 0 and 1 ( "return the smallest [ correct answer ]" ).

    I have no idea how you would arrive at 15; it might have helped if you had explained that.

  • Default User Avatar

    I cant figure this out "Note that any element of the array can only be counted in one Perfect Pair. Also if there are multiple correct answers, return the smallest one.", I dont understant why the answer to the following case is 10 and not 15.

    kata.Pairwise(new int[]{0, 0, 0, 0, 1, 1},1);

    if in the previous case the answer is 10, then what is the answer of the following:

    kata.Pairwise(new int[]{0, 0, 1, 1, 0, 0},1);

  • Default User Avatar

    The same thing happened to me, you have to validate when the rank goes through 0, for example (-5 to 1), (-1 to 4), (4 to -2), (7 to -4), in all that cases you dont have to count the rank 0.