back to home

soapyigu / LeetCode-Swift

Solutions to LeetCode by Swift

4,965 stars
901 forks
36 issues
Swift

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing soapyigu/LeetCode-Swift in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/soapyigu/LeetCode-Swift)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

LeetCode by Swift LeetCode Online Judge is a website containing many **algorithm questions**. Most of them are real interview questions of **Google, Facebook, LinkedIn, Apple**, etc. This repo shows my solutions by Swift with the code style strictly follows the RayWenderlich Swift Style Guide. Please feel free to reference and **STAR** to support this repo, thank you! Progress Problem Status shows the latest progress to all 1000+ questions. Currently we have 400+ completed solutions. Note: questions with ♥ mark means that you have to **Subscript to premium membership** of LeetCode to unlock them. Contributors Data Structures • Array • String • Linked List • Stack • Queue • Tree • Dynamic programming • Depth-first search • Breadth-first search • Math • Search • Sort • Graph • Design Companies • Google • Facebook • Snapchat • Uber • Airbnb • LinkedIn • Amazon • Microsoft Array | Title | Solution | Difficulty | Time | Space | | ----- | -------- | ---------- | ---- | ----- | Verify an Alien Dictionary|Swift| Easy| O(n)| O(n)| Sort Array By Parity|Swift| Easy| O(n)| O(n)| Max Consecutive Ones| Swift| Easy| O(n)| O(1)| Heaters| Swift| Easy| O(nlogn)| O(1)| Number of Boomerangs| Swift| Easy| O(n ^ 2)| O(n)| Island Perimeter| Swift| Easy| O(nm)| O(1)| Majority Element| Swift| Easy| O(n)| O(1)| Majority Element II| Swift| Medium| O(n)| O(1)| First Missing Positive| Swift| Hard| O(n)| O(n)| Intersection of Two Arrays| Swift| Easy| O(n)| O(n)| Intersection of Two Arrays II| Swift| Easy| O(n)| O(n)| Contains Duplicate| Swift| Easy| O(n)| O(n)| Contains Duplicate II| Swift| Easy| O(n)| O(n)| Remove Duplicates from Sorted Array| Swift| Easy| O(n)| O(1)| Remove Duplicates from Sorted Array II| Swift| Medium| O(n)| O(1)| Move Zeroes| Swift| Easy| O(n)| O(1)| Remove Element| Swift| Easy| O(n)| O(1)| Strobogrammatic Number| Swift| Easy| O(n)| O(1)| Can Place Flowers| Swift| Easy| O(n)| O(1)| Two Sum| Swift| Easy| O(n)| O(n)| Two Sum II - Input array is sorted| Swift| Easy| O(n)| O(1)| Two Sum III - Data structure design| Swift| Easy| O(n)| O(1)| Two Sum Less Than K| Swift| Easy| O(nlogn)| O(n)| 3Sum| Swift| Medium| O(n^2)| O(nC3)| 3Sum Closest| Swift| Medium| O(n^2)| O(nC3)| 4Sum| Swift| Medium| O(n^3)| O(nC4)| Increasing Triplet Subsequence| Swift| Medium| O(n)| O(1)| Summary Ranges| Swift| Medium| O(n)| O(n)| Range Sum Query 2D - Immutable| Swift| Medium| O(mn)| O(mn)| Missing Ranges| Swift| Medium| O(n)| O(1)| Asteroid Collision| Swift| Medium| O(n)| O(n)| Maximize Distance to Closest Person| Swift| Easy| O(n)| O(1)| Exam Room| Swift| Medium| O(n)| O(n)| Shortest Word Distance| Swift| Easy| O(n)| O(1)| Shortest Word Distance II| Swift| Medium| O(n)| O(n)| Shortest Word Distance III| Swift| Medium| O(n)| O(1)| Minimum Size Subarray Sum| Swift| Medium| O(n)| O(1)| Maximum Size Subarray Sum Equals k| Swift| Medium| O(n)| O(n)| Smallest Range| Swift| Hard | O(nm)| O(nm)| Product of Array Except Self| Swift| Medium| O(n)| O(1)| Rotate Array| Swift| Easy| O(n)| O(1)| Rotate Image| Swift| Medium| O(n^2)| O(1)| Spiral Matrix| Swift| Medium| O(n^2)| O(1)| Spiral Matrix II| Swift| Medium| O(n^2)| O(1)| Diagonal Traverse| Swift| Medium| O(mn)| O(1)| Valid Sudoku| Swift| Easy| O(n^2)| O(n)| Set Matrix Zero| Swift| Medium| O(n^2)| O(1)| Next Permutation| Swift| Medium| O(n)| O(1)| Gas Station| Swift| Medium| O(n)| O(1)| Game of Life| Swift| Medium| O(n)| O(1)| Task Scheduler| Swift| Medium| O(nlogn)| O(n)| Validate IP Address| Swift| Medium| O(n)| O(1)| Sliding Window Maximum | Swift| Hard| O(n)| O(n)| Longest Consecutive Sequence| Swift| Hard| O(n)| O(n)| Create Maximum Number| Swift| Hard| O(n^2)| O(n)| Find All Numbers Disappeared in an Array| Swift| Easy| O(n)| O(1)| String | Title | Solution | Difficulty | Time | Space | | ----- | -------- | ---------- | ---- | ----- | Fizz Buzz| Swift| Easy| O(n)| O(1)| First Unique Character in a String| Swift| Easy| O(n)| O(1)| Keyboard Row| Swift| Easy| O(nm)| O(n)| Valid Word Abbreviation| Swift| Easy| O(n)| O(n)| Valid Palindrome| Swift| Easy| O(n)| O(n)| Valid Palindrome II| Swift| Easy| O(n)| O(n)| Detect Capital| Swift| Easy| O(n)| O(1)| Count and Say| Swift| Easy| O(n^2)| O(1)| Flip Game| Swift| Easy| O(n)| O(n)| Implement strStr()| Swift| Easy| O(nm)| O(n)| Isomorphic Strings| Swift| Easy| O(n)| O(n)| Reverse String| Swift| Easy| O(n)| O(n)| Reverse String II| Swift| Easy| O(n)| O(n)| Reverse Vowels of a String| Swift| Easy| O(n)| O(n)| Reverse Words in a String| Swift| Medium| O(n)| O(1)| Reverse Words in a String II| Swift| Medium| O(n)| O(1)| Reverse Words in a String III| Swift| Easy| O(n)| O(1)| Length of Last Word| Swift| Easy| O(n)| O(n)| String Compression| Swift| Easy| O(n)| O(1)| Add Strings| Swift| Easy| O(n)| O(1)| Shortest Distance to a Character| Swift| Easy| O(n)| O(1)| Multiply Strings| Swift| Medium| O(n)| O(1)| Palindrome Permutation| Swift| Easy| O(n)| O(n)| Valid Anagram| Swift| Easy| O(n)| O(n)| Ransom Note| Swift| Easy| O(n)| O(n)| Group Anagrams| Swift| Medium| O(nmlogm + nlogn)| O(n) Find Duplicate File in System| Swift| Medium| O(nm)| O(n) Longest Common Prefix| Swift| Easy| O(nm)| O(m)| Longest Substring Without Repeating Characters| Swift| Medium| O(n)| O(n)| One Edit Distance| Swift| Medium| O(n)| O(n)| Word Pattern| Swift| Easy| O(n)| O(n)| Permutation in String| Swift| Medium| O(nm)| O(n)| Find All Anagrams in a String| Swift| Medium| O(n)| O(n)| Minimum Window Substring| Swift| Hard| O(n^2)| O(n)| Longest Substring with At Most Two Distinct Characters| Swift| Hard| O(n)| O(n)| Longest Substring with At Most K Distinct Characters| Swift| Hard| O(n)| O(n)| Text Justification| Swift| Hard| O(n)| O(n)| Find the Closest Palindrome| Swift| Hard| O(n)| O(n)| Linked List | Title | Solution | Difficulty | Time | Space | | ----- | -------- | ---------- | ---- | ----- | Reverse Linked List| Swift| Easy| O(n)| O(1)| Palindrome Linked List| Swift| Easy| O(n)| O(1)| Swap Nodes in Pairs| Swift| Easy| O(n)| O(1)| Remove Linked List Eleme…