3Sum
Last updated
What is 3Sum?
Given an array of integers, find all unique triplets that sum to zero. You sort the array first, then for each element use two pointers to find pairs that complete the triplet. The sort plus two pointers bring it from O(n³) to O(n²). This problem teaches you to extend the two pointer technique beyond pairs and introduces how sorting enables smarter traversal.
Free resources to learn 3Sum
- Article3Sum - LeetCode
- Video3Sum (Updated Solution)
- Video3 Sum (LeetCode 15)
More in stage 5: Two Pointers
3Sum: common questions
Can I learn 3Sum in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain 3Sum in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this 3Sum tutorial for beginners?
It is lesson 21 of 137 in the free LeetCode roadmap, in stage 5, Two Pointers. If you are new to LeetCode, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.