Back to course home
0% completed
Vote For New Content
What is the point of " i < arr.length - 2" in the JS solution? I've been writing...
Ada
Feb 21, 2022
What is the point of " i < arr.length - 2" in the JS solution? I've been writing my solutions in Swift from the JS answers. I tried "
0
0
Comments
Comments
A
Ada 4 years ago
Why isn't the rest of my comment showing??
Design Gurus4 years ago
Because we need to find a triplet. In each loop iteration, we fix "i", and then find the other two number from the right side. Which means the right side should have at least two numbers. Hence, "i" can't point to the last two elements of the array.
On this page
Problem Statement
Try it yourself