Ad
  • Custom User Avatar

    About the edit, you're right, the value should be inserted at the end, and that's why it fails.

  • Custom User Avatar

    but im not expecting the value to check to be in the array, i find the index of the first element in the array which the value to search for is less than. the 1st solution should work.

    edit- unless the 2 remaining cases should be at end of arr. in which case I am an idiot. Will check when on pc later

  • Custom User Avatar
  • Custom User Avatar

    Your code being wrong is not a kata issue, see the sample test it fails and you'll see why it fails. The value to insert is not always already contained in the array that's why your code returns -1. About your second solution, it now fails 100% of the time.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Needs random tests.

    Also, I've seen something like this before. It may or may not be an exact duplicate ( ISTR indices in the other's {} templates ).