Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Is there a reason why the outer loop is iterating from 0 to array.length-2 inste...

Ben Cornia

Jan 18, 2023

Is there a reason why the outer loop is iterating from 0 to array.length-2 instead of array.length-1?

Is it to prevent iterating through an array whose length is less than 4?

0

0

Comments
Comments
B
Ben Cornia3 years ago

*less than 3

Design Gurus
Design Gurus2 years ago

The last two elements can't give you a triplet, therefore, we can ignore searching for a triplet from the second last element.

On this page

Problem Statement

Try it yourself