Back to course home
0% completed
Vote For New Content
As a side note for this question as well. arr.length - 2 in the initial for loop...
CaptainKidd
Jan 18, 2023
As a side note for this question as well. arr.length - 2 in the initial for loop is unnecessary. While technically correct as you will get the correct answer you need only look at earlier examples of the 3 sum style problem to see that it works fine without.
Technically you are narrowing down the number of times the for loop needs to iterate but it's such a small amount that any savings would be safely ignored in simplified time complexity analysis.
1
0
Comments
Comments
On this page
Problem Statement
Try it yourself