Grokking Oracle Coding Interview
Ask Author
Back to course home

0% completed

Vote For New Content
Ariel Davies
You don't need to check for duplicates for all 3 elements

Ariel Davies

May 19, 2024

You only need to ensure two of the three numbers are not repeating. Because if 2 of the 3 are unique then the triplet is inherently unique. The second while loop for adjusting the right pointer is not necessary and makes the solution a more confusing.

0

0

Comments
Comments
S
Sidd Mittala year ago

good point - but the second while loop also increases efficiency. If there are duplicate right pointer elements, you may as well skip them since only 1 valid left pointer element will be able to sum all numbers to 0. (see there test example, it illustrates it quite well...

On this page