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

0% completed

Vote For New Content
Example 1 explanation is incorrect

himanshu1495

Oct 30, 2023

Why are we mentioning the second triplet with a sum less than 3, the output is 2 because the sum of the first triplet -1,0,3 is 2 which is as close as possible (distance of 1) to the target of 3.

The second triplet in the example wouldn't even be considered because our algorithm always tries to move closer to the target so it will not consider that triplet.

@Design Gurus guys please fix this

0

0

Comments
Comments

On this page

Problem Statement

Solution

Algorithm Walkthrough

Code

Complexity Analysis

Time Complexity

Space Complexity