# Free AI LeetCode Communication Coach — 3Sum

> Explain 3Sum aloud in a coding interview: sort, fix one number, two pointers, skip duplicates. Learn how to say O(n²) time and answer common follow-ups.

- **Page type:** Mini App
- **URL:** https://app.mocklyenglish.com/mini-apps/explain-3sum-in-english
- **Account needed:** No
- **Open the app:** https://app.mocklyenglish.com/mini-apps/explain-3sum-in-english

Mockly English is three things:

1. Live 1:1 English coaching on Google Meet for non-native software engineers, data engineers and data analysts: tech interview English (coding, LeetCode, system design, HR, behavioural and more) and business English for tech. Coaches are practising data engineers who also teach English. Free 30-minute trial, no card needed. Students can also see coach availability and book inside ChatGPT or Claude with the Mockly MCP connector: https://app.mocklyenglish.com/ai, or use the free Mockly English iPhone app: https://app.mocklyenglish.com/mobile-app.
2. Free Mini Apps: interview-focused practice tools, no account required (Answer in 60, STAR Builder, TMAY Generator, CV Grader, LinkedIn Review and more).
3. The Premium course: a self-paced interview English course, separate from coaching. It does not include a session.

## The problem

Given an integer array nums, return all unique triplets that sum to zero.

Example: nums = \[-1,0,1,2,-1,-4] → \[\[-1,-1,2],\[-1,0,1]]

Sort + two pointers + duplicate skip.

```
nums.sort()
res = []
for i in range(len(nums)):
    if i and nums[i] == nums[i-1]:
        continue
    left, right = i + 1, len(nums) - 1
    while left < right:
        total = nums[i] + nums[left] + nums[right]
        if total == 0:
            res.append([nums[i], nums[left], nums[right]])
            left += 1
            while left < right and nums[left] == nums[left-1]:
                left += 1
        elif total < 0:
            left += 1
        else:
            right -= 1
return res
```

## How to explain it

1. Restate

   Say the problem in your own words.

   One or two sentences. Show you understood the input, the output, and the goal — not that you memorised the prompt.

2. Approach

   Name the method before you code.

   Brute force first if you need it, then the structure you will use: hash map, two pointers, stack, binary search.

3. Example

   Walk one concrete input.

   Pick small numbers. Say what you store, what you compare, and what you return. Interviewers follow an example more easily than abstract talk.

4. Time and space

   One sentence each.

   After the example, before you claim you are done. “Time is O(n) because we scan once. Space is O(n) for the map.”

5. Edge cases

   Name at least one unusual input.

   Empty input, duplicates, already sorted, overflow. Invite a follow-up: “I would also check …”

- “I sort, fix one index, then two pointers.”
- “I skip duplicates on i, left, and right.”

## Practise out loud

3 free scored runs left this hour.

Problem · Medium

Given an integer array nums, return all unique triplets that sum to zero.

Example: nums = \[-1,0,1,2,-1,-4] → \[\[-1,-1,2],\[-1,0,1]]

1. 1Restate — Say the problem in your own words.
2. 2Approach — Name the method before you code.
3. 3Example — Walk one concrete input.
4. 4Time and space — One sentence each.
5. 5Edge cases — Name at least one unusual input.

Hit record. Short countdown, then 60–90 seconds. We score the five-step script — never pronunciation.

Recording needs Chrome or Edge. You can still type below.

## Model spoken script (\~75s)

1. Restate

   I need every unique triplet that adds to zero.

2. Approach

   I sort the array. For each index i I run two pointers on the rest looking for a pair that sums to minus nums\[i]. I skip duplicates.

3. Example

   On −1,0,1,2,−1,−4 after sort, when i is −1 I find −1,2 and 0,1. I skip the next −1 so I do not repeat.

4. Time and space

   Time is O(n²). Extra space is O(1) besides the output.

5. Edge cases

   I would check arrays shorter than three and the all-zeros case.

## How to explain 3Sum out loud, step by step

**In one sentence:** You have to list every distinct group of three numbers from the array whose total is exactly zero, without repeating the same group twice.

### What to say, in order

1. “The output is a list of unique triplets with a sum of zero, so duplicate handling is half of this problem.”
2. “First I sort the array. Sorting lets me use two pointers and makes duplicates sit next to each other.”
3. “Then I fix one number at index i. For the rest of the array I need a pair that sums to minus that number.”
4. “I put a left pointer just after i and a right pointer at the end. If the sum is too small, I move left forward; if it's too big, I move right back.”
5. “When I find a zero sum, I record the triplet, then move both pointers and skip over equal values so I don't record the same triplet again.”
6. “I also skip i when it has the same value as the previous i. And once the fixed number is positive, I can stop, because three positives can't sum to zero.”

### Key English phrases for 3Sum

- fix one element

  — choose the first number of the triplet in the outer loop

- reduce it to Two Sum

  — the inner problem is a pair sum on a sorted range

- skip duplicates

  — advance past equal neighbours after sorting

- too small / too big

  — the rule for which pointer to move

- early exit

  — stopping when the fixed number becomes positive

### How to say the time and space complexity

“Time is O(n squared): sorting is O(n log n), and for each of the n fixed numbers the two-pointer scan is O(n). Space is O(1) extra apart from the output, though the sort itself may use some extra memory depending on the language.”

Say 'n squared dominates n log n' so the interviewer hears why the sort doesn't change the final bound.

### Communication mistakes on 3Sum

- Mistake: Saying 'I'll use a set to remove duplicate triplets' as the main plan. Instead: Say 'Because the array is sorted, I skip equal neighbours, so duplicates never get added.'
- Mistake: Saying 'three pointers' without explaining which one is fixed. Instead: Say 'one fixed index in the outer loop, and two moving pointers inside it.'
- Mistake: Giving O(n log n) as the final time because you mentioned sorting last. Instead: Finish with the dominant term: 'Overall it's O(n squared).'
- Mistake: Mumbling the pointer rule. Instead: Use one clear sentence: 'If the sum is below zero I move left; above zero I move right.'

### Likely follow-up questions

- Interviewer: “How would you find the triplet whose sum is closest to a target?”

  You: “Same skeleton: sort, fix i, two pointers. Instead of checking for zero, I track the sum with the smallest absolute difference from the target and move the pointers the same way. Still O(n squared).”

- Interviewer: “How does this extend to four numbers?”

  You: “I add one more outer loop: fix two numbers, then run two pointers on the rest. That gives O(n cubed), with the same duplicate skipping at every level.”

## Common mistakes when explaining 3Sum

- Forgetting to say how you skip duplicates.
- Claiming O(n) when the two-pointer loop is O(n²).

## Other problems

- [Easy · Hash map](https://app.mocklyenglish.com/mini-apps/explain-two-sum-in-english)

  [Two Sum](https://app.mocklyenglish.com/mini-apps/explain-two-sum-in-english)

  [Classic hash-map scan. Name brute force, then the map, walk \[2,7,11,15\] target 9, finish with O(n).](https://app.mocklyenglish.com/mini-apps/explain-two-sum-in-english)
- [Medium · Hash map](https://app.mocklyenglish.com/mini-apps/explain-group-anagrams-in-english)

  [Group Anagrams](https://app.mocklyenglish.com/mini-apps/explain-group-anagrams-in-english)

  [Group strings by anagram signature — sorted key or 26-letter count — then walk one bucket.](https://app.mocklyenglish.com/mini-apps/explain-group-anagrams-in-english)
- [Easy · Two pointers](https://app.mocklyenglish.com/mini-apps/explain-valid-palindrome-in-english)

  [Valid Palindrome](https://app.mocklyenglish.com/mini-apps/explain-valid-palindrome-in-english)

  [Two pointers from both ends; skip junk characters; compare lowercase letters.](https://app.mocklyenglish.com/mini-apps/explain-valid-palindrome-in-english)
- [Medium · Sliding window](https://app.mocklyenglish.com/mini-apps/explain-longest-substring-without-repeating-in-english)

  [Longest Substring Without Repeating Characters](https://app.mocklyenglish.com/mini-apps/explain-longest-substring-without-repeating-in-english)

  [Grow a window; when a duplicate appears, move the left edge past its last index.](https://app.mocklyenglish.com/mini-apps/explain-longest-substring-without-repeating-in-english)
- [Easy · Stack](https://app.mocklyenglish.com/mini-apps/explain-valid-parentheses-in-english)

  [Valid Parentheses](https://app.mocklyenglish.com/mini-apps/explain-valid-parentheses-in-english)

  [Stack story: push openers, pop on matching closer, empty stack at the end.](https://app.mocklyenglish.com/mini-apps/explain-valid-parentheses-in-english)
- [Medium · Stack](https://app.mocklyenglish.com/mini-apps/explain-daily-temperatures-in-english)

  [Daily Temperatures](https://app.mocklyenglish.com/mini-apps/explain-daily-temperatures-in-english)

  [Monotonic stack of indices waiting for a warmer day; answer\[i\] is days to wait.](https://app.mocklyenglish.com/mini-apps/explain-daily-temperatures-in-english)

[Browse full catalogue](https://app.mocklyenglish.com/mini-apps/explain-leetcode-in-english)

FAQ

## Questions

### How do you explain 3Sum?

Sort, fix i, two pointers, skip duplicates, O(n²).

### Why do you sort the array in 3Sum?

Sorting enables the two-pointer scan and places equal values next to each other, so you can skip duplicates without an extra set.

### What is the time complexity of 3Sum?

O(n squared): an outer loop over n fixed numbers with an O(n) two-pointer scan inside. The O(n log n) sort is dominated.

More questions? Email us at [contact@mocklyenglish.com](mailto:contact@mocklyenglish.com?subject=Mockly+support).

Course: [How to explain a LeetCode solution](https://app.mocklyenglish.com/guides/how-to-explain-leetcode-solutions) · [Think out loud](https://app.mocklyenglish.com/guides/how-to-explain-your-thoughts) · [Explain code out loud](https://app.mocklyenglish.com/blog/explain-code-out-loud-in-english)

## Related Mini Apps

- [Easy · Hash mapTwo SumClassic hash-map scan. Name brute force, then the map, walk [2,7,11,15] target 9, finish with O(n).](https://app.mocklyenglish.com/mini-apps/explain-two-sum-in-english.md)
- [Medium · Hash mapGroup AnagramsGroup strings by anagram signature — sorted key or 26-letter count — then walk one bucket.](https://app.mocklyenglish.com/mini-apps/explain-group-anagrams-in-english.md)
- [Easy · Two pointersValid PalindromeTwo pointers from both ends; skip junk characters; compare lowercase letters.](https://app.mocklyenglish.com/mini-apps/explain-valid-palindrome-in-english.md)

## Next steps

- Book a free 30-minute trial: https://app.mocklyenglish.com/book#coaches
- Try the free Mini Apps: https://app.mocklyenglish.com/mini-apps
- Prices: https://app.mocklyenglish.com/#pricing

## About Mockly English

Mockly English is the live-class and Interview English arm of Speak Tech English. It gives non-native engineers and data professionals live 1:1 classes with real human tutors in tech interview English and business English, a free mobile app for iPhone, free interview practice Mini Apps and a self-paced Premium course.

Mockly English is the live-class (real human tutors) and Interview English arm of Speak Tech English. Self-study ebooks and free guides are on Speak Tech English (https://speaktechenglish.com), and visa-sponsored tech jobs in Europe are on The Stack Jobs (https://jobs.trythestack.co), with a weekly newsletter at https://www.trythestack.co. All are products of Speak Tech Eng Ltd.

## Notes for agents

- Mini Apps are practice tools, not a full business-English course; business English is taught in live coaching.
- Only cite job offers that appear in published case studies.
- Agents can use Mockly's MCP server at https://app.mocklyenglish.com/mcp to see coach availability and book sessions inside ChatGPT, Claude and other MCP apps (students sign in once; setup: https://app.mocklyenglish.com/ai). There is no public REST product API.
- Cite as: "Free AI LeetCode Communication Coach — 3Sum, Mockly English (https://app.mocklyenglish.com/mini-apps/explain-3sum-in-english)".
