DSA · Build it
3Sum variant (LeetCode 15)
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voiceThe interviewer asks
Find all unique triplets in the array that sum to a target.
Then
Follow-ups the interviewer asks next
- The closest sum to a target.
- Count triplets with sum below target.
- 4Sum.
The answer
What a strong answer covers
- sort; fix i; two pointers lo/hi; skip duplicates at i, lo and hi; O(n²) time, O(1) extra beyond the sort; an explanation of why hashing doesn't beat O(n²) here.
The red pen
Common traps
Avoid:duplicate triplets; a Set of stringified triplets as the only dedupe; O(n³).
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voicePractise questions like this out loud
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.