Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

nums =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Sort the array, then for each fixed first element use a two-pointer scan to find pairs that complete sum 0.

Approach

  1. Sort.
  2. Loop i over possible first elements, skipping duplicates.
  3. Use l=i+1, r=n-1. Move pointers based on the sum.
  4. When a triplet is found, skip duplicates for l and r.

Why it works

Sorting enables the two-pointer technique and makes duplicate skipping straightforward.

Code
Loading...
Complexity
Time: O(n^2)
Space: O(1)
Solution
Updated: 2026-02-23

Idea

Sort the array, then for each fixed first element use a two-pointer scan to find pairs that complete sum 0.

Approach

  1. Sort.
  2. Loop i over possible first elements, skipping duplicates.
  3. Use l=i+1, r=n-1. Move pointers based on the sum.
  4. When a triplet is found, skip duplicates for l and r.

Why it works

Sorting enables the two-pointer technique and makes duplicate skipping straightforward.

Code
Loading...
Complexity
Time: O(n^2)
Space: O(1)