Need help with Leetcode_Solutions_Swift?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

jindulys
120 Stars 15 Forks MIT License 343 Commits 0 Opened issues

Description

Leetcode solutions with Swift

Services available

!
?

Need anything else?

Contributors list

# 35,064
Swift
uicolle...
Objecti...
ios-fra...
301 commits

LeetcodeSolutions

Leetcode Solutions Swift

Leetcode solutions in Swift

Current Finished: 131

String(19)

|Problem | Category | Difficulty | Space | Time |
|--------------- | -------------------- | --------------- | ------------------ |--------| 3 Longest Substring without repeating characters | String | Medium | O(n) | O(n) | 14 Longest Common Prefix | String | Easy | O(nm) | O(mn) | 28 Implement strStr | String | Easy | O(n) | O(mn) | 49 Group Anagrams | String | Medium | O(Nmlgm) | O(N)| 58 Length of Last Word | String | Easy | O(n) | O(n) | 165 Compare Version Numbers | String | Easy | O(n) | O(n)| 205 Isomorphic Strings | String | Easy | O(n) | O(n) | 242 Valid Anagram | String | Easy | O(n) | O(n)| 293 Flip Game :lock: | String | Easy | O(N) | O(N)| 294 Flip Game :lock: | String | Medium | O(2^(n/2)) | O(2^(n/2))| 290 Word Pattern | String | Easy | O(n) | O(n)| 340 Longest SubString with At Most K Distinct Characters :lock: | String | Hard | O(1) | O(N)| 344 Reverse String | String | Easy | O(n) | O(n)| 345 Reverse Vowels of a String | String | Easy | O(n) | O(n) 383 Ransom Note | String | Easy | O(n) | O(n) | 388 Longest Absolute File Path Solution | String | Medium | O(N) | O(N)| 389 Find the difference | String & hash table | Easy | O(n) | O(n)| 394 Decode String | String | Medium | O(N) | O(N)| 418 Sentence Screen Fitting :lock: | String | Medium | O(1) | O(row * col)|

Array(22)

|Problem | Category | Difficulty | Space | Time |
|--------------- | -------------------- | --------------- | -------------------|--------| 1 Two Sum | Array | Easy | O(n) | O(n)| 15 3Sum | Array | Medium | O(n) | O(n^2)| 18 4Sum | Array | Medium | O(N^2) | O(N^4)| 26 Remove Duplicates from sorted array | Array | Easy | O(N) | O(N)| 27 Remove Element | Array | Easy | O(1) | O(n)| 36 Valid Sudoku | Array | Easy | O(1) | O(1)| 48 Rotate Image | Array | Medium | O(1) | O(n^2)| 80 Remove Duplicates from sorted array II | Array | Medium | O(N) | O(N)| 189 Rotate Array | Array | Easy | O(1) | O(n)| 217 Contains Duplicate | Array | Easy | O(n) | O(n) | 228 Summary Ranges | Array | Medium | O(n) | O(n)| 260 Single Number III | Array/Bit | Medium | O(1) | O(n)| 283 Move Zeroes | Array | Easy | O(1) | O(n)| 303 Range Sum Query - Immutable | Array | Easy | O(N) | O(N)| 304 Range Sum Query 2D - Immutable | Array | Medium | O(N^2) | O(N^2)| 308 Range Sum Query 2D - Mutable | Array | Hard | O(N^2) | O(N^2)| 349 Intersection of two arrays | Array | Easy | O(n) | O(n)| 350 Intersection of two arrays II | Array | Easy | O(n) | O(n)| 361 Bomb Enemy :lock: | Array | Medium | O(N) | O(MN)| 457 Circular Array Loop | Array | Medium | O(1) | O(N)| 621 Task Scheduler | Array | Medium | O(1) | O(N)| 645 Set Mismatch | Array | Medium | O(N) | O(N)|

Tree(20)

|Problem | Category | Difficulty | Space | Time |
|--------------- | -------------------- | --------------- | -------------------|--------| 98 Validate Binary Search Tree | Tree | Medium | O(n) | O(n)| 100 Same Tree | Tree | Easy | O(n) | O(n)| 101 Symmetric Tree | Tree | Easy | O(n) | O(n)| 102 Binary Tree Level Order Traversal | Tree | Easy | O(n) | O(n)| 104 Maximum Depth of Binary Tree | Tree | Easy | O(n) | O(n)| 105 Construct Binary Tree From Preorder and InOorer Traversal | Tree | Medium | O(n) | O(n)| 106 Construct Binary Tree From Inorder and Postorder Traversal | Tree | Medium | O(n) | O(n)| 107 Binary Tree Level Order Traversal II | Tree | Easy | O(N) | O(N)| 110 Balanced Binary Tree | Tree | Easy | O(n) | O(n)| 111 Minimum Depth Of Binary Tree | Tree | Easy | O(n) | O(n)| 112 Path Sum | Tree | Easy | O(n) | O(n)| 113 Path Sum II | Tree | Medium | O(n) | O(n)| 124 Binary Tree Maximum Path Sum | Tree | Hard | O(n) | O(n^2)(Memoized - O(n))| 226 Invert Binary Tree | Tree | Easy | O(n) | O(n)| 235 Lowest Common Ancestor of a Binary Search Tree | Tree | Medium | O(n) | O(n)| 236 Lowest Common Ancestor of a Binary Tree | Tree | Medium | O(n) | O(n)| 337 House Robber III | Tree | Medium | O(n) | O(n)| 437 Path Sum III | Tree | Easy | O(n) | O(n)| 450 Delete Node in a BST | Tree | Medium | O(1) | O(lgn)| 655 Print Binary Tree | Tree | Medium | O(N) | O(N)|

Graph(1)

|Problem | Category | Difficulty | Space | Time | |--------------- | -------------------- | --------------- | -------------------|--------| 207 Course Schedule | Graph | Medium | O(|V| + |E|) | O(|V| + |E|)|

Search(9)

|Problem | Category | Difficulty | Space | Time |
|--------------- | -------------------- | --------------- | -------------------|--------| 33 Search in rotated sorted array | Search | Hard | O(1) | O(lgn)| 34 Search for a Range | Search | Medium | O(1) | O(lgn)| 35 Search Insert Position | Search | Medium | O(1) | O(lgn)| 69 Sqrtx | Search | Medium | O(1) | O(lgn)| 81 Search in rotated sorted array II | Search | Medium | O(1) | O(n)| 153 Find Minimum in Rotated Sorted Array | Search | Medium | O(1) | O(lgn)| 154 Find Minimum in Rotated Sorted Array II | Search | Medium | O(1) | O(n)| 162 Find Peak Element | Search | Medium | O(1) | O(lgn)| 278 First Bad Version | Binary Search | Easy | O(1) | O(lgn)|

Linked List(8)

|Problem | Category | Difficulty | Space | Time |
|--------------- | -------------------- | --------------- | -------------------|--------| 2 Add Two Numbers | LinkedList | Medium | O(n) | O(n)| 24 Swap Nodes in Pairs | Linked List | Easy | O(1) | O(n)| 61 Rotate List | Linked List | Medium | O(1) | O(N)| 83 Remove Duplicates From Sorted List | Linked List | Easy | O(1) | O(N)| 86 Partition List | Linked List | Medium | O(1) | O(N)| 141 Reorder List | Linked List | Medium | O(1) | O(N)| 206 Reverse LinkedList | Linked List | Easy | O(1) | O(N)| 445 Add Two Numbers II | Linked List | Medium | O(1) | O(N)|

DynamicProgramming(18)

|Problem | Category | Difficulty | Space | Time | |--------------- | -------------------- | --------------- | -------------------|--------| 5 Longest Palindromic Substring | DP | Medium | O(n^2) | O(n^2)| 53 Maximum Subarray | DP | Medium | O(n) | O(n)| 55 Jump Game | DP | Medium | O(n) | O(n)| 62 Unique Paths | DP | Medium | O(mn) | O(mn)| 63 Unique Paths II | DP | Medium | O(mn) | O(mn)| 64 Minimum Path Sum | DP | Medium | O(mn) | O(mn)| 70 Climbing Stairs | DP | Easy | O(1) | O(N)| 72 Edit Distance | DP | Hard | O(NM) | O(NM)| 121 Best Time to Buy and Sell Stock | DP | Easy | O(1) | O(N)| 139 Word Break | DP | Medium | O(n) | O(nL^2)| 152 Maximum Product Subarray | DP | Medium | O(1) | O(n)| 198 House Robber | DP | Easy | O(n) | O(n)| 213 House Robber II | DP | Medium | O(n) | O(n)| 221 Maximal Square | DP | Medium | O(MN) | O(MN)| 279 Unique Paths II | DP | Medium | O(n) | O(n^2)| 300 Longest Increasing Subsequence | DP | Medium | O(n) | O(n^2)| 322 Coin Change | DP | Medium | O(n^2) | O(n)| 377 Combination Sum IV | Dynamic Programming | Medium | O(N) | O(n^(target/min(n)))|

Stack(7)

|Problem | Category | Difficulty | Space | Time |
|--------------- | -------------------- | --------------- | -------------------|--------| 20 Valid Parentheses | Stack | Easy | O(N) | O(N)| 94 Binary Tree In order Traversal | Stack | Medium | O(N) | O(N)| 144 Binary Tree Preorder Traversal | Stack | Medium | O(N) | O(N)| 145 Binary Tree Post Order Traversal | Stack | Hard | O(N) | O(N)| 224 Basic Calculator | Stack | Hard | O(N) | O(N)| 227 Basic Calculator II | Stack | Medium | O(N) | O(N)| 772 Basic Calculator III | Stack | Hard | O(N) | O(N)|

Heap(2)

|Problem | Category | Difficulty | Space | Time |
|--------------- | -------------------- | --------------- | -------------------|--------| 23 Merge K Sorted Lists | Heap | Hard | O(N) | O(Nlgk)| 295 Find Median From Data Stream | Heap | Hard | O(N) | O(1) || O(lgN)|

Queue(1)

|Problem | Category | Difficulty | Space | Time |
|--------------- | -------------------- | --------------- | -------------------|--------| 346 Moving Average from Data Stream :lock: | Queue | Easy | O(N) | O(1)|

Sort(3)

|Problem | Category | Difficulty | Space | Time |
|--------------- | -------------------- | --------------- | -------------------|--------| 75 Sort Colors | Sort | Medium | O(NlgN) | O(N)| 347 Top K Frequent Element | Sort | Medium | O(klgk) | O(N)| 56 Merge Intervals | Sort | Medium | O(NlgN) | O(N)|

DFS(8)

|Problem | Category | Difficulty | Space | Time |
|--------------- | -------------------- | --------------- | -------------------|--------| 46 Permutations | DFS | Medium | O(N!) | O(N!)| 47 Permutations II | DFS | Medium | O(N!) | O(N!)| 77 Combinations | DFS | Medium | O(N^K) | O(KN^K)| 78 Subsets | DFS | Medium | O(2^N) | O(2^N)| 79 Word Search | DFS | Medium | O(3^N) | O(N^2)| 90 Subsets II | DFS | Medium | O(2^N) | O(2^N)| 212 Word Search II | DFS | Hard | O(N3^N) | O(N^2)| 638 ShoppingOffers | DFS | Medium | O(N) | O(N^2)|

BFS(1)

|Problem | Category | Difficulty | Space | Time |
|--------------- | -------------------- | --------------- | -------------------|--------| 317 Shortest Distance from All Buildings :lock: | BFS | Easy | O(MN) | O(KMN)|

Math(11)

|Problem | Category | Difficulty | Space | Time |
|--------------- | -------------------- | --------------- | -------------------|--------| 7 Reverse Integer | Math | Easy | O(1) | O(1)| 8 String to Integer(atoi) | Math String | Easy | O(n) | O(1)| 9 Palindrome Number | Math | Easy | O(1) | O(1)| 136 Single Number | Math | Easy | O(1) | O(n)| 223 Rectangle Area | Math | Easy | O(1) | O(1)| 231 Power of Two | Math | Easy | O(1) | O(1)| 258 Add Digits | Math | Easy | O(1) | O(1)| 263 Ugly Number | Math | Easy | O(1) | O(1)| 326 Power of Three | Math | Easy | O(1) | O(1)| 338 Counting Bits | Math | Medium | O(N) | O(N)| 400 Nth Digit | Math | Easy | O(lgN) | O(1)|

[Google]

|Problem | Category | Difficulty | Space | Time |
|--------------- | -------------------- | --------------- | -------------------|--------| 294 Flip Game :lock: | String | Medium | O(2^(n/2)) | O(2^(n/2))| 308 Range Sum Query 2D - Mutable | Array | Hard | O(N^2) | O(N^2)| 317 Shortest Distance from All Buildings :lock: | BFS | Easy | O(MN) | O(KMN)| 340 Longest SubString with At Most K Distinct Characters :lock: | String | Hard | O(1) | O(N)| 346 Moving Average from Data Stream :lock: | Queue | Easy | O(N) | O(1)| 361 Bomb Enemy :lock: | Array | Medium | O(N) | O(MN)| 388 Longest Absolute File Path Solution | String | Medium | O(N) | O(N)| 394 Decode String | String | Medium | O(N) | O(N)| 418 Sentence Screen Fitting :lock: | String | Medium | O(1) | O(row * col)| 482 LicenseKey Formatting Solution | String | Medium | O(n) | O(n)|

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.