We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I tried that already, but some test cases are failing.
pair is an array of the values whose indexes we need for the answer (not important, but obtained through a binary search on a sorted version of the array).
This code iterates over each value in pair, left value first. For each value, it executes a linear search on the original, unsorted flavours array. Once it locates the value, it prints the current index and sets the value to false so that when looking for the second value, if it's a duplicate, it will not fund the first occurence (it will be false, at this stage). We then break the loop because we no longer need to do anything more on the current loop.
I can't see why some test cases are failing, though. Ideas?
Ice Cream Parlor
You are viewing a single comment's thread. Return to all comments →
I tried that already, but some test cases are failing.
pair
is an array of the values whose indexes we need for the answer (not important, but obtained through a binary search on a sorted version of the array).This code iterates over each value in
pair
, left value first. For each value, it executes a linear search on the original, unsorted flavours array. Once it locates the value, it prints the current index and sets the value tofalse
so that when looking for the second value, if it's a duplicate, it will not fund the first occurence (it will befalse
, at this stage). We then break the loop because we no longer need to do anything more on the current loop.I can't see why some test cases are failing, though. Ideas?