Grokking Oracle Coding Interview
Ask Author
Back to course home

0% completed

Vote For New Content
I cannot find an explanation why do we run searchPair method starting from i+1. ...

Mikhail Putilov

Aug 14, 2022

I cannot find an explanation why do we run searchPair method starting from i+1. Why do we just throw out left part of the array from 0 to i during searchPair?

0

0

Comments
Comments
M
Mikhail Putilov3 years ago

That part seems to be slipped from explanation. I think I know the answer but I don't think that it is some trivial piece of logic.

Ok, my reasoning about it: every found triplet can be found by fixing i as a first element of the triplet. In the first example, first tr...

Design Gurus
Design Gurus3 years ago

We need to find a triplet, arr[i] is one number, we search for the other two numbers from i+1 onwards.

We do this for every 'i', that is for every number.

Once we are at 'i'th index, we don't need to search number left of 'i', as we have already searched that part.

On this page