ζθ εθοΌεΏ ζδΈεΎγ
As an idiot of algorithms, I make bold to resolve the problems on LeetCode, especially, in Swift. Most of the algorithms were not figured out by myself.
PLEASE DO NOT CONTRIBUTE until I accomplish all of them.
let π = "Easy", π = "Medium", π¨ = "Hard", γοΈ = "require premium membership"
- 1 π Two Sum .swift
- 2 π Add Two Numbers .swift
- 3 π Longest Substring Without Repeating Characters
- 4 π¨ Median of Two Sorted Arrays
- 5 π Longest Palindromic Substring
- 6 π ZigZag Conversion .swift
- 7 π Reverse Integer .swift
- 8 π String to Integer (atoi) .swift
- 9 π Palindrome Number .swift
- 10 π¨ Regular Expression Matching
- 11 π Container With Most Water
- 12 π Integer to Roman
- 13 π Roman to Integer .swift
- 14 π Longest Common Prefix .swift
- 15 π 3Sum
- 16 π 3Sum Closest
- 17 π Letter Combinations of a Phone Number
- 18 π 4Sum
- 19 π Remove Nth Node From End of List .swift
- 20 π Valid Parentheses .swift
- 21 π Merge Two Sorted Lists .swift
- 22 π Generate Parentheses
- 23 π¨ Merge k Sorted Lists
- 24 π Swap Nodes in Pairs
- 25 π¨ Reverse Nodes in k-Group
- 26 π Remove Duplicates from Sorted Array .swift
- 27 π Remove Element .swift
- 28 π Implement strStr() .swift
- 29 π Divide Two Integers
- 30 π¨ Substring with Concatenation of All Words
- 31 π Next Permutation
- 32 π¨ Longest Valid Parentheses
- 33 π¨ Search in Rotated Sorted Array
- 34 π Search for a Range
- 35 π Search Insert Position
- 36 π Valid Sudoku
- 37 π¨ Sudoku Solver
- 38 π Count and Say .swift
- 39 π Combination Sum
- 40 π Combination Sum II
- 41 π¨ First Missing Positive
- 42 π¨ Trapping Rain Water
- 43 π Multiply Strings
- 44 π¨ Wildcard Matching
- 45 π¨ Jump Game II
- 46 π Permutations
- 47 π Permutations II
- 48 π Rotate Image
- 49 π Group Anagrams .swift
- 50 π Pow(x, n)
- 51 π¨ N-Queens
- 52 π¨ N-Queens II
- 53 π Maximum Subarray
- 54 π Spiral Matrix
- 55 π Jump Game
- 56 π¨ Merge Intervals
- 57 π¨ Insert Interval
- 58 π Length of Last Word .swift
- 59 π Spiral Matrix II
- 60 π Permutation Sequence
- 61 π Rotate List
- 62 π Unique Paths
- 63 π Unique Paths II
- 64 π Minimum Path Sum
- 65 π¨ Valid Number .swift
- 66 π Plus One .swift
- 67 π Add Binary .swift
- 68 π¨ Text Justification
- 69 π Sqrt(x)
- 70 π Climbing Stairs
- 71 π Simplify Path
- 72 π¨ Edit Distance
- 73 π Set Matrix Zeroes
- 74 π Search a 2D Matrix
- 75 π Sort Colors
- 76 π¨ Minimum Window Substring
- 77 π Combinations
- 78 π Subsets
- 79 π Word Search
- 80 π Remove Duplicates from Sorted Array II
- 81 π Search in Rotated Sorted Array II
- 82 π Remove Duplicates from Sorted List II .swift
- 83 π Remove Duplicates from Sorted List .swift
- 84 π¨ Largest Rectangle in Histogram
- 85 π¨ Maximal Rectangle
- 86 π Partition List
- 87 π¨ Scramble String
- 88 π Merge Sorted Array .swift
- 89 π Gray Code
- 90 π Subsets II
- 91 π Decode Ways
- 92 π Reverse Linked List II
- 93 π Restore IP Addresses
- 94 π Binary Tree Inorder Traversal
- 95 π Unique Binary Search Trees II
- 96 π Unique Binary Search Trees
- 97 π¨ Interleaving String
- 98 π Validate Binary Search Tree
- 99 π¨ Recover Binary Search Tree
- 100 π Same Tree .swift
- 101 π Symmetric Tree .swift
- 102 π Binary Tree Level Order Traversal
- 103 π Binary Tree Zigzag Level Order Traversal
- 104 π Maximum Depth of Binary Tree .swift
- 105 π Construct Binary Tree from Preorder and Inorder Traversal
- 106 π Construct Binary Tree from Inorder and Postorder Traversal
- 107 π Binary Tree Level Order Traversal II
- 108 π Convert Sorted Array to Binary Search Tree
- 109 π Convert Sorted List to Binary Search Tree
- 110 π Balanced Binary Tree .swift
- 111 π Minimum Depth of Binary Tree .swift
- 112 π Path Sum
- 113 π Path Sum II
- 114 π Flatten Binary Tree to Linked List .swift
- 115 π¨ Distinct Subsequences
- 116 π Populating Next Right Pointers in Each Node
- 117 π¨ Populating Next Right Pointers in Each Node II
- 118 π Pascal's Triangle
- 119 π Pascal's Triangle II
- 120 π Triangle
- 121 π Best Time to Buy and Sell Stock
- 122 π Best Time to Buy and Sell Stock II
- 123 π¨ Best Time to Buy and Sell Stock III
- 124 π¨ Binary Tree Maximum Path Sum
- 125 π Valid Palindrome
- 126 π¨ Word Ladder II
- 127 π Word Ladder
- 128 π¨ Longest Consecutive Sequence
- 129 π Sum Root to Leaf Numbers
- 130 π Surrounded Regions
- 131 π Palindrome Partitioning
- 132 π¨ Palindrome Partitioning II
- 133 π Clone Graph
- 134 π Gas Station
- 135 π¨ Candy
- 136 π Single Number
- 137 π Single Number II
- 138 π¨ Copy List with Random Pointer
- 139 π Word Break
- 140 π¨ Word Break II
- 141 π Linked List Cycle
- 142 π Linked List Cycle II
- 143 π Reorder List
- 144 π Binary Tree Preorder Traversal
- 145 π¨ Binary Tree Postorder Traversal
- 146 π¨ LRU Cache
- 147 π Insertion Sort List
- 148 π Sort List
- 149 π¨ Max Points on a Line
- 150 π Evaluate Reverse Polish Notation
- 151 π Reverse Words in a String
- 152 π Maximum Product Subarray
- 153 π Find Minimum in Rotated Sorted Array
- 154 π¨ Find Minimum in Rotated Sorted Array II
- 155 π Min Stack .swift
- 156 π Binary Tree Upside Down γοΈ
- 157 π Read N Characters Given Read4 γοΈ
- 158 π¨ Read N Characters Given Read4 II - Call multiple times γοΈ
- 159 π¨ Longest Substring with At Most Two Distinct Characters γοΈ
- 160 π Intersection of Two Linked Lists
- 161 π One Edit Distance γοΈ
- 162 π Find Peak Element
- 163 π Missing Ranges γοΈ
- 164 π¨ Maximum Gap
- 165 π Compare Version Numbers .swift
- 166 π Fraction to Recurring Decimal
- 167 π Two Sum II - Input array is sorted γοΈ
- 168 π Excel Sheet Column Title
- 169 π Majority Element
- 170 π Two Sum III - Data structure design γοΈ
- 171 π Excel Sheet Column Number
- 172 π Factorial Trailing Zeroes
- 173 π Binary Search Tree Iterator
- 174 π¨ Dungeon Game
- 179 π Largest Number
- 186 π Reverse Words in a String II γοΈ
- 187 π Repeated DNA Sequences
- 188 π¨ Best Time to Buy and Sell Stock IV
- 189 π Rotate Array .swift
- 190 π Reverse Bits
- 191 π Number of 1 Bits
- 198 π House Robber
- 199 π Binary Tree Right Side View
- 200 π Number of Islands
- 201 π Bitwise AND of Numbers Range
- 202 π Happy Number
- 203 π Remove Linked List Elements
- 204 π Count Primes
- 205 π Isomorphic Strings
- 206 π Reverse Linked List
- 207 π Course Schedule
- 208 π Implement Trie (Prefix Tree)
- 209 π Minimum Size Subarray Sum
- 210 π Course Schedule II
- 211 π Add and Search Word - Data structure design
- 212 π¨ Word Search II
- 213 π House Robber II
- 214 π¨ Shortest Palindrome
- 215 π Kth Largest Element in an Array
- 216 π Combination Sum III
- 217 π Contains Duplicate
- 218 π¨ The Skyline Problem
- 219 π Contains Duplicate II
- 220 π Contains Duplicate III
- 221 π Maximal Square
- 222 π Count Complete Tree Nodes
- 223 π Rectangle Area
- 224 π Basic Calculator
- 225 π Implement Stack using Queues
- 226 π Invert Binary Tree .swift
- 227 π Basic Calculator II
- 228 π Summary Ranges
- 229 π Majority Element II
- 230 π Kth Smallest Element in a BST
- 231 π Power of Two
- 232 π Implement Queue using Stacks
- 233 π Number of Digit One
- 234 π Palindrome Linked List
- 235 π Lowest Common Ancestor of a Binary Search Tree
- 236 π Lowest Common Ancestor of a Binary Tree
- 237 π Delete Node in a Linked List
- 238 π Product of Array Except Self
- 239 π¨ Sliding Window Maximum
- 240 π Search a 2D Matrix II
- 241 π Different Ways to Add Parentheses
- 242 π Valid Anagram .swift
- 243 π Shortest Word Distance γοΈ
- 244 π Shortest Word Distance II γοΈ
- 245 π Shortest Word Distance III γοΈ
- 246 π Strobogrammatic Number γοΈ
- 247 π Strobogrammatic Number II γοΈ
- 248 π¨ Strobogrammatic Number III γοΈ
- 249 π Group Shifted Strings γοΈ
- 250 π Count Univalue Subtrees γοΈ
- 251 π Flatten 2D Vector γοΈ
- 252 π Meeting Rooms γοΈ
- 253 π Meeting Rooms II γοΈ
- 254 π Factor Combinations γοΈ
- 255 π Verify Preorder Sequence in Binary Search Tree γοΈ
- 256 π Paint House γοΈ
- 257 π Binary Tree Paths
- 258 π Add Digits .swift
- 259 π 3Sum Smaller γοΈ
- 260 π Single Number III
- 261 π Graph Valid Tree γοΈ
- 263 π Ugly Number .swift
- 264 π Ugly Number II
- 265 π¨ Paint House II γοΈ
- 266 π Palindrome Permutation γοΈ
- 267 π Palindrome Permutation II γοΈ
- 268 π Missing Number
- 269 π¨ Alien Dictionary γοΈ
- 270 π Closest Binary Search Tree Value γοΈ
- 271 π Encode and Decode Strings γοΈ
- 272 π¨ Closest Binary Search Tree Value II γοΈ
- 273 π Integer to English Words
- 274 π H-Index
- 275 π H-Index II
- 276 π Paint Fence γοΈ
- 277 π Find the Celebrity γοΈ
- 278 π First Bad Version
- 279 π Perfect Squares
- 280 π Wiggle Sort γοΈ
- 281 π Zigzag Iterator γοΈ
- 282 π¨ Expression Add Operators
- 283 π Move Zeroes .swift
- 284 π Peeking Iterator
- 285 π Inorder Successor in BST γοΈ
- 286 π Walls and Gates γοΈ
- 287 π¨ Find the Duplicate Number
- 288 π Unique Word Abbreviation γοΈ
- 289 π Game of Life
- 290 π Word Pattern
- 291 π¨ Word Pattern II γοΈ
- 292 π Nim Game
- 293 π Flip Game γοΈ
- 294 π Flip Game II γοΈ
- 295 π¨ Find Median from Data Stream
- 296 π¨ Best Meeting Point γοΈ
- 297 π Serialize and Deserialize Binary Tree
- 298 π Binary Tree Longest Consecutive Sequence γοΈ
- 299 π Bulls and Cows
- 300 π Longest Increasing Subsequence
- 301 π¨ Remove Invalid Parentheses
- 302 π¨ Smallest Rectangle Enclosing Black Pixels γοΈ
- 303 π Range Sum Query - Immutable
- 304 π Range Sum Query 2D - Immutable
- 305 π¨ Number of Islands II γοΈ
- 306 π Additive Number
- 307 π Range Sum Query - Mutable
- 308 π¨ Range Sum Query 2D - Mutable γοΈ
- 309 π Best Time to Buy and Sell Stock with Cooldown
- 310 π Minimum Height Trees
- 311 π Sparse Matrix Multiplication γοΈ
- 312 π¨ Burst Balloons
- 313 π Super Ugly Number
- 314 π Binary Tree Vertical Order Traversal γοΈ
- 315 π¨ Count of Smaller Numbers After Self
- 316 π Remove Duplicate Letters
- 317 π¨ Shortest Distance from All Buildings γοΈ
- 318 π Maximum Product of Word Lengths
- 319 π Bulb Switcher
- 320 π Generalized Abbreviation γοΈ
- 321 π¨ Create Maximum Number
- 322 π Coin Change
- 323 π Number of Connected Components in an Undirected Graph γοΈ
- 324 π Wiggle Sort II
- 325 π Maximum Size Subarray Sum Equals k γοΈ
- 326 π Power of Three .swift
- 327 π¨ Count of Range Sum
Open the project with Xcode 7.2 then press β + u
.
Or run rake test
in this folder if you have xctool installed.
Copyright (C) 2016 lexrus.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.