LeetCode Swift Solutions
This section explains common LeetCode problems using Swift. The goal is not only to show a final answer, but to make the reasoning clear enough that you can rebuild the solution during an interview.
Every problem page is written around the same structure: what the problem is asking, the core idea, step-by-step reasoning, Swift implementation notes, complexity, and edge cases to remember. That makes the pages useful for both quick review and slower study.
How To Use These Solutions
- Read the problem summary and identify the pattern: hash map, two pointers, sorting, set lookup, or bucket counting.
- Try to explain the approach before looking at the code.
- Walk through at least one sample input by hand.
- Study the Swift-specific details, especially dictionary updates, array mutation, and character handling.
- Re-implement the solution without copying it.
Problem Index
Core Patterns Covered
- Hash map lookup for complements and frequency counts
- Two-pointer scans on sorted arrays and character arrays
- In-place array mutation
- Set-based sequence detection
- Sorting with duplicate skipping
- Bucket-based frequency selection
For language foundations, review Swift collection types, Swift strings and characters, and Swift control flow.
Last updated: June 27, 2026