LeetCode.swift
ๆ่ ๅ่๏ผๅฟ ๆไธๅพใ
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.
let ๐ = "Easy", ๐ = "Medium", ๐จ = "Hard", ใ๏ธ = "require premium membership"
- 1
๐ Two Sum .swift - 2
๐ Add Two Numbers .swift - 3
๐ Longest Substring Without Repeating Characters .swift - 4
๐จ Median of Two Sorted Arrays - 5
๐ Longest Palindromic Substring .swift - 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 .swift - 13
๐ Roman to Integer .swift - 14
๐ Longest Common Prefix .swift - 15
๐ 3Sum - 16
๐ 3Sum Closest - 17
๐ Letter Combinations of a Phone Number .swift - 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
๐ Find First and Last Position of Element in Sorted Array - 35
๐ Search Insert Position .swift - 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 .swift - 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 .swift - 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 - 328
๐ Odd Even Linked List - 329
๐จ Longest Increasing Path in a Matrix - 330
๐จ Patching Array - 331
๐ Verify Preorder Serialization of a Binary Tree - 332
๐ Reconstruct Itinerary - 333
๐ Largest BST Subtreeใ๏ธ - 334
๐ Increasing Triplet Subsequence - 335
๐จ Self Crossing - 336
๐จ Palindrome Pairs - 337
๐ House Robber III - 338
๐ Counting Bits - 339
๐ Nested List Weight Sumใ๏ธ - 340
๐จ Longest Substring with At Most K Distinct Charactersใ๏ธ - 341
๐ Flatten Nested List Iterator - 342
๐ Power of Four - 343
๐ Integer Break - 344
๐ Reverse String - 345
๐ Reverse Vowels of a String - 346
๐ Moving Average from Data Streamใ๏ธ - 347
๐ Top K Frequent Elements - 348
๐ Design Tic-Tac-Toeใ๏ธ - 349
๐ Intersection of Two Arrays - 350
๐ Intersection of Two Arrays II - 351
๐ Android Unlock Patternsใ๏ธ - 352
๐จ Data Stream as Disjoint Intervals - 353
๐ Design Snake Gameใ๏ธ - 354
๐จ Russian Doll Envelopes - 355
๐ Design Twitter - 356
๐ Line Reflectionใ๏ธ - 357
๐ Count Numbers with Unique Digits - 358
๐จ Rearrange String k Distance Apartใ๏ธ - 359
๐ Logger Rate Limiterใ๏ธ - 360
๐ Sort Transformed Arrayใ๏ธ - 361
๐ Bomb Enemyใ๏ธ - 362
๐ Design Hit Counterใ๏ธ - 363
๐จ Max Sum of Rectangle No Larger Than K - 364
๐ Nested List Weight Sum IIใ๏ธ - 365
๐ Water and Jug Problem - 366
๐ Find Leaves of Binary Treeใ๏ธ - 367
๐ Valid Perfect Square - 368
๐ Largest Divisible Subset - 369
๐ Plus One Linked Listใ๏ธ - 370
๐ Range Additionใ๏ธ - 371
๐ Sum of Two Integers - 372
๐ Super Pow - 373
๐ Find K Pairs with Smallest Sums - 374
๐ Guess Number Higher or Lower - 375
๐ Guess Number Higher or Lower II - 376
๐ Wiggle Subsequence - 377
๐ Combination Sum IV - 378
๐ Kth Smallest Element in a Sorted Matrix - 379
๐ Design Phone Directoryใ๏ธ - 380
๐ Insert Delete GetRandom O(1) - 381
๐จ Insert Delete GetRandom O(1) - Duplicates allowed - 382
๐ Linked List Random Node - 383
๐ Ransom Note - 384
๐ Shuffle an Array - 385
๐ Mini Parser - 386
๐ Lexicographical Numbers - 387
๐ First Unique Character in a String - 388
๐ Longest Absolute File Path - 389
๐ Find the Difference - 390
๐ Elimination Game - 391
๐จ Perfect Rectangle - 392
๐ Is Subsequence - 393
๐ UTF-8 Validation - 394
๐ Decode String - 395
๐ Longest Substring with At Least K Repeating Characters - 396
๐ Rotate Function - 397
๐ Integer Replacement - 398
๐ Random Pick Index - 399
๐ Evaluate Division - 400
๐ Nth Digit - 401
๐ Binary Watch - 402
๐ Remove K Digits - 403
๐จ Frog Jump - 404
๐ Sum of Left Leaves - 405
๐ Convert a Number to Hexadecimal - 406
๐ Queue Reconstruction by Height - 407
๐จ Trapping Rain Water II - 408
๐ Valid Word Abbreviationใ๏ธ - 409
๐ Longest Palindrome - 410
๐จ Split Array Largest Sum - 411
๐จ Minimum Unique Word Abbreviationใ๏ธ - 412
๐ Fizz Buzz - 413
๐ Arithmetic Slices - 414
๐ Third Maximum Number - 415
๐ Add Strings - 416
๐ Partition Equal Subset Sum - 417
๐ Pacific Atlantic Water Flow - 418
๐ Sentence Screen Fittingใ๏ธ - 419
๐ Battleships in a Board - 420
๐จ Strong Password Checker - 421
๐ Maximum XOR of Two Numbers in an Array - 422
๐ Valid Word Squareใ๏ธ - 423
๐ Reconstruct Original Digits from English - 424
๐ Longest Repeating Character Replacement - 425
๐จ Word Squaresใ๏ธ - 432
๐จ All O`one Data Structure - 433
๐ Minimum Genetic Mutation - 434
๐ Number of Segments in a String - 435
๐ Non-overlapping Intervals - 436
๐ Find Right Interval - 437
๐ Path Sum III - 438
๐ Find All Anagrams in a String - 439
๐ Ternary Expression Parserใ๏ธ - 440
๐จ K-th Smallest in Lexicographical Order - 441
๐ Arranging Coins - 442
๐ Find All Duplicates in an Array - 443
๐ String Compression - 444
๐ Sequence Reconstructionใ๏ธ - 445
๐ Add Two Numbers II - 446
๐จ Arithmetic Slices II - Subsequence - 447
๐ Number of Boomerangs - 448
๐ Find All Numbers Disappeared in an Array - 449
๐ Serialize and Deserialize BST - 450
๐ Delete Node in a BST - 451
๐ Sort Characters By Frequency - 452
๐ Minimum Number of Arrows to Burst Balloons - 453
๐ Minimum Moves to Equal Array Elements - 454
๐ 4Sum II - 455
๐ Assign Cookies - 456
๐ 132 Pattern - 457
๐ Circular Array Loop - 458
๐ Poor Pigs - 459
๐ Repeated Substring Pattern - 460
๐จ LFU Cache - 461
๐ Hamming Distance .swift - 462
๐ Minimum Moves to Equal Array Elements II - 463
๐ Island Perimeter - 464
๐ Can I Win - 465
๐จ Optimal Account Balancingใ๏ธ - 466
๐จ Count The Repetitions - 467
๐ Unique Substrings in Wraparound String - 468
๐ Validate IP Address - 469
๐ Convex Polygonใ๏ธ - 471
๐จ Encode String with Shortest Lengthใ๏ธ - 472
๐จ Concatenated Words - 473
๐ Matchsticks to Square - 474
๐ Ones and Zeroes - 475
๐ Heaters - 476
๐ Number Complement .swift - 477
๐ Total Hamming Distance - 479
๐ Largest Palindrome Product - 480
๐จ Sliding Window Median - 481
๐ Magical String - 482
๐ License Key Formatting - 483
๐จ Smallest Good Base - 484
๐ Find Permutationใ๏ธ - 485
๐ Max Consecutive Ones - 486
๐ Predict the Winner - 487
๐ Max Consecutive Ones IIใ๏ธ - 488
๐จ Zuma Game - 490
๐ The Mazeใ๏ธ - 491
๐ Increasing Subsequences - 492
๐ Construct the Rectangle - 493
๐จ Reverse Pairs - 494
๐ Target Sum - 495
๐ Teemo Attacking - 496
๐ Next Greater Element I - 498
๐ Diagonal Traverse - 499
๐จ The Maze IIIใ๏ธ - 500
๐ Keyboard Row - 501
๐ Find Mode in Binary Search Tree - 502
๐จ IPO - 503
๐ Next Greater Element II - 504
๐ Base 7 .swift - 505
๐ The Maze IIใ๏ธ - 506
๐ Relative Ranks - 507
๐ Perfect Number - 508
๐ Most Frequent Subtree Sum - 513
๐ Find Bottom Left Tree Value - 514
๐จ Freedom Trail - 515
๐ Find Largest Value in Each Tree Row - 516
๐ Longest Palindromic Subsequence - 517
๐จ Super Washing Machines - 518
๐ Coin Change 2 - 520
๐ Detect Capital .swift - 521
๐ Longest Uncommon Subsequence I - 522
๐ Longest Uncommon Subsequence II - 523
๐ Continuous Subarray Sum - 524
๐ Longest Word in Dictionary through Deleting - 525
๐ Contiguous Array - 526
๐ Beautiful Arrangement - 527
๐จ Word Abbreviationใ๏ธ - 529
๐ Minesweeper - 530
๐ Minimum Absolute Difference in BST - 531
๐ Lonely Pixel Iใ๏ธ - 532
๐ K-diff Pairs in an Array - 533
๐ Lonely Pixel IIใ๏ธ - 535
๐ Encode and Decode TinyURL - 536
๐ Construct Binary Tree from Stringใ๏ธ - 537
๐ Complex Number Multiplication - 538
๐ Convert BST to Greater Tree - 539
๐ Minimum Time Difference - 540
๐ Single Element in a Sorted Array - 541
๐ Reverse String II - 542
๐ 01 Matrix - 543
๐ Diameter of Binary Tree - 544
๐ Output Contest Matchesใ๏ธ - 545
๐ Boundary of Binary Treeใ๏ธ - 546
๐จ Remove Boxes - 547
๐ Friend Circles - 548
๐ Split Array with Equal Sumใ๏ธ - 549
๐ Binary Tree Longest Consecutive Sequence IIใ๏ธ - 551
๐ Student Attendance Record I - 552
๐จ Student Attendance Record II - 553
๐ Optimal Division - 554
๐ Brick Wall - 555
๐ Split Concatenated Stringsใ๏ธ - 556
๐ Next Greater Element III - 557
๐ Reverse Words in a String III - 560
๐ Subarray Sum Equals K - 561
๐ Array Partition I - 562
๐ Longest Line of Consecutive One in Matrixใ๏ธ - 563
๐ Binary Tree Tilt - 564
๐จ Find the Closest Palindrome - 565
๐ Array Nesting - 566
๐ Reshape the Matrix - 567
๐ Permutation in String - 568
๐จ Maximum Vacation Daysใ๏ธ - 572
๐ Subtree of Another Tree - 573
๐ Squirrel Simulationใ๏ธ - 575
๐ Distribute Candies - 576
๐ Out of Boundary Paths - 581
๐ Shortest Unsorted Continuous Subarray - 582
๐ Kill Processใ๏ธ - 583
๐ Delete Operation for Two Strings - 587
๐จ Erect the Fence - 588
๐จ Design In-Memory File Systemใ๏ธ - 591
๐จ Tag Validator - 592
๐ Fraction Addition and Subtraction - 593
๐ Valid Square - 594
๐ Longest Harmonious Subsequence - 598
๐ Range Addition II - 599
๐ Minimum Index Sum of Two Lists - 600
๐จ Non-negative Integers without Consecutive Ones - 604
๐ Design Compressed String Iteratorใ๏ธ - 605
๐ Can Place Flowers - 606
๐ Construct String from Binary Tree - 609
๐ Find Duplicate File in System - 611
๐ Valid Triangle Number - 616
๐ Add Bold Tag in Stringใ๏ธ - 617
๐ Merge Two Binary Trees - 621
๐ Task Scheduler - 623
๐ Add One Row to Tree - 624
๐ Maximum Distance in Arraysใ๏ธ - 625
๐ Minimum Factorizationใ๏ธ - 628
๐ Maximum Product of Three Numbers - 629
๐จ K Inverse Pairs Array - 630
๐จ Course Schedule III - 631
๐จ Design Excel Sum Formulaใ๏ธ - 632
๐จ Smallest Range - 633
๐ Sum of Square Numbers - 634
๐ Find the Derangement of An Arrayใ๏ธ - 635
๐ Design Log Storage Systemใ๏ธ - 636
๐ Exclusive Time of Functions - 637
๐ Average of Levels in Binary Tree - 638
๐ Shopping Offers - 639
๐จ Decode Ways II - 640
๐ Solve the Equation - 642
๐จ Design Search Autocomplete Systemใ๏ธ - 643
๐ Maximum Average Subarray I - 644
๐จ Maximum Average Subarray IIใ๏ธ - 645
๐ Set Mismatch - 646
๐ Maximum Length of Pair Chain - 647
๐ Palindromic Substrings - 648
๐ Replace Words - 649
๐ Dota2 Senate - 650
๐ 2 Keys Keyboard - 651
๐ 4 Keys Keyboardใ๏ธ - 652
๐ Find Duplicate Subtrees - 653
๐ Two Sum IV - Input is a BST - 654
๐ Maximum Binary Tree - 655
๐ Print Binary Tree - 656
๐จ Coin Pathใ๏ธ - 657
๐ Judge Route Circle - 658
๐ Find K Closest Elements - 659
๐ Split Array into Consecutive Subsequences - 660
๐จ Remove 9ใ๏ธ - 661
๐ Image Smoother - 662
๐ Maximum Width of Binary Tree - 663
๐ Equal Tree Partitionใ๏ธ - 664
๐จ Strange Printer - 665
๐ Non-decreasing Array - 666
๐ Path Sum IVใ๏ธ - 667
๐ Beautiful Arrangement II - 668
๐จ Kth Smallest Number in Multiplication Table - 669
๐ Trim a Binary Search Tree - 670
๐ Maximum Swap - 671
๐ Second Minimum Node In a Binary Tree - 672
๐ Bulb Switcher II - 673
๐ Number of Longest Increasing Subsequence - 674
๐ Longest Continuous Increasing Subsequence - 675
๐จ Cut Off Trees for Golf Event - 676
๐ Implement Magic Dictionary - 677
๐ Map Sum Pairs - 678
๐ Valid Parenthesis String - 679
๐จ 24 Game - 680
๐ Valid Palindrome II - 681
๐ Next Closest Timeใ๏ธ - 682
๐ Baseball Game - 683
๐จ K Empty Slotsใ๏ธ - 684
๐ Redundant Connection - 685
๐จ Redundant Connection II - 686
๐ Repeated String Match - 687
๐ Longest Univalue Path - 688
๐ Knight Probability in Chessboard - 689
๐จ Maximum Sum of 3 Non-Overlapping Subarrays - 690
๐ Employee Importance - 691
๐จ Stickers to Spell Word - 692
๐ Top K Frequent Words - 693
๐ Binary Number with Alternating Bits - 694
๐ Number of Distinct Islandsใ๏ธ - 695
๐ Max Area of Island - 696
๐ Count Binary Substrings - 697
๐ Degree of an Array - 698
๐ Partition to K Equal Sum Subsets - 699
๐จ Falling Squares - 711
๐จ Number of Distinct Islands IIใ๏ธ - 712
๐ Minimum ASCII Delete Sum for Two Strings - 713
๐ Subarray Product Less Than K - 714
๐ Best Time to Buy and Sell Stock with Transaction Fee - 715
๐จ Range Module - 716
๐จ Max Stackใ๏ธ - 717
๐ 1-bit and 2-bit Characters - 718
๐ Maximum Length of Repeated Subarray - 719
๐จ Find K-th Smallest Pair Distance - 720
๐ Longest Word in Dictionary - 721
๐ Accounts Merge - 722
๐ Remove Comments - 723
๐ Candy Crushใ๏ธ - 724
๐ Find Pivot Index - 725
๐ Split Linked List in Parts - 726
๐จ Number of Atoms - 727
๐จ Minimum Window Subsequenceใ๏ธ - 728
๐ Self Dividing Numbers - 729
๐ My Calendar I - 730
๐จ Count Different Palindromic Subsequences - 731
๐ My Calendar II - 732
๐จ My Calendar III - 733
๐ Flood Fill - 734
๐ Sentence Similarityใ๏ธ - 735
๐ Asteroid Collision - 736
๐จ Parse Lisp Expression - 737
๐ Sentence Similarity IIใ๏ธ - 738
๐ Monotone Increasing Digits - 739
๐ Daily Temperatures - 740
๐ Delete and Earn - 741
๐จ Cherry Pickup - 709
๐ To Lower Case - 742
๐ Closest Leaf in a Binary Treeใ๏ธ - 743
๐ Network Delay Time - 744
๐ Find Smallest Letter Greater Than Target - 745
๐จ Prefix and Suffix Search - 746
๐ Min Cost Climbing Stairs - 747
๐ Largest Number At Least Twice of Others - 748
๐ Shortest Completing Word - 749
๐จ Contain Virus - 750
๐ Number Of Corner Rectanglesใ๏ธ - 751
๐ IP to CIDRใ๏ธ - 752
๐ Open the Lock - 753
๐จ Cracking the Safe - 754
๐ Reach a Number - 755
๐ Pour Waterใ๏ธ - 756
๐ Pyramid Transition Matrix - 426
๐ Convert Binary Search Tree to Sorted Doubly Linked Listใ๏ธ - 757
๐จ Set Intersection Size At Least Two - 758
๐ Bold Words in Stringใ๏ธ - 759
๐จ Employee Free Timeใ๏ธ - 760
๐ Find Anagram Mappingsใ๏ธ - 761
๐จ Special Binary String - 429
๐ N-ary Tree Level Order Traversal - 428
๐จ Serialize and Deserialize N-ary Treeใ๏ธ - 430
๐ Flatten a Multilevel Doubly Linked List - 762
๐ Prime Number of Set Bits in Binary Representation - 763
๐ Partition Labels - 764
๐ Largest Plus Sign - 765
๐จ Couples Holding Hands - 431
๐จ Encode N-ary Tree to Binary Treeใ๏ธ - 427
๐ Construct Quad Tree - 558
๐ Quad Tree Intersection - 559
๐ Maximum Depth of N-ary Tree - 589
๐ N-ary Tree Preorder Traversal - 590
๐ N-ary Tree Postorder Traversal - 766
๐ Toeplitz Matrix - 767
๐ Reorganize String - 768
๐จ Max Chunks To Make Sorted II - 769
๐ Max Chunks To Make Sorted - 770
๐จ Basic Calculator IV - 771
๐ Jewels and Stones - 700
๐ Search in a Binary Search Tree - 701
๐ Insert into a Binary Search Tree - 772
๐จ Basic Calculator IIIใ๏ธ - 702
๐ Search in a Sorted Array of Unknown Sizeใ๏ธ - 773
๐จ Sliding Puzzle - 774
๐จ Minimize Max Distance to Gas Stationใ๏ธ - 703
๐ Kth Largest Element in a Stream - 775
๐ Global and Local Inversions - 776
๐ Split BSTใ๏ธ - 704
๐ Binary Search - 777
๐ Swap Adjacent in LR String - 778
๐จ Swim in Rising Water - 779
๐ K-th Symbol in Grammar - 780
๐จ Reaching Points - 781
๐ Rabbits in Forest - 782
๐จ Transform to Chessboard - 783
๐ Minimum Distance Between BST Nodes - 784
๐ Letter Case Permutation - 785
๐ Is Graph Bipartite? - 786
๐จ K-th Smallest Prime Fraction - 787
๐ Cheapest Flights Within K Stops - 788
๐ Rotated Digits .swift - 789
๐ Escape The Ghosts - 790
๐ Domino and Tromino Tiling - 791
๐ Custom Sort String - 792
๐ Number of Matching Subsequences - 793
๐จ Preimage Size of Factorial Zeroes Function - 794
๐ Valid Tic-Tac-Toe State - 795
๐ Number of Subarrays with Bounded Maximum - 796
๐ Rotate String .swift - 797
๐ All Paths From Source to Target - 798
๐จ Smallest Rotation with Highest Score - 799
๐ Champagne Tower - 705
๐ Design HashSet - 706
๐ Design HashMap - 800
๐ Similar RGB Colorใ๏ธ - 801
๐ Minimum Swaps To Make Sequences Increasing - 802
๐ Find Eventual Safe States - 803
๐จ Bricks Falling When Hit - 804
๐ Unique Morse Code Words .swift - 805
๐จ Split Array With Same Average - 806
๐ Number of Lines To Write String .swift - 807
๐ Max Increase to Keep City Skyline - 808
๐ Soup Servings - 809
๐ Expressive Words - 810
๐จ Chalkboard XOR Game - 811
๐ Subdomain Visit Count .swift - 812
๐ Largest Triangle Area - 813
๐ Largest Sum of Averages - 814
๐ Binary Tree Pruning - 815
๐จ Bus Routes - 816
๐ Ambiguous Coordinates - 817
๐ Linked List Components - 818
๐จ Race Car - 819
๐ Most Common Word .swift - 707
๐ Design Linked List - 820
๐ Short Encoding of Words - 821
๐ Shortest Distance to a Character - 822
๐ Card Flipping Game - 823
๐ Binary Trees With Factors - 708
๐ Insert into a Cyclic Sorted Listใ๏ธ - 824
๐ Goat Latin .swift - 825
๐ Friends Of Appropriate Ages - 826
๐ Most Profit Assigning Work - 827
๐จ Making A Large Island - 828
๐จ Unique Letter String - 829
๐ Consecutive Numbers Sum - 830
๐ Positions of Large Groups .swift - 831
๐ Masking Personal Information - 641
๐ Design Circular Deque - 622
๐ Design Circular Queue - 832
๐ Flipping an Image .swift - 833
๐ Find And Replace in String - 834
๐จ Sum of Distances in Tree - 835
๐ Image Overlap - 489
๐จ Robot Room Cleanerใ๏ธ - 836
๐ Rectangle Overlap .swift - 837
๐ New 21 Game - 838
๐ Push Dominoes - 839
๐จ Similar String Groups - 840
๐ Magic Squares In Grid .swift - 841
๐ Keys and Rooms - 842
๐ Split Array into Fibonacci Sequence - 843
๐จ Guess the Word - 844
๐ Backspace String Compare .swift - 845
๐ Longest Mountain in Array - 846
๐ Hand of Straights - 847
๐จ Shortest Path Visiting All Nodes - 848
๐ Shifting Letters - 849
๐ Maximize Distance to Closest Person - 850
๐จ Rectangle Area II - 851
๐ Loud and Rich - 852
๐ Peak Index in a Mountain Array .swift - 853
๐ Car Fleet - 854
๐จ K-Similar Strings - 855
๐ Exam Room - 856
๐ Score of Parentheses - 857
๐จ Minimum Cost to Hire K Workers - 858
๐ Mirror Reflection - 859
๐ Buddy Strings .swift - 860
๐ Lemonade Change .swift - 861
๐ Score After Flipping Matrix - 862
๐จ Shortest Subarray with Sum at Least K - 863
๐ All Nodes Distance K in Binary Tree - 710
๐จ Random Pick with Blacklist - 864
๐จ Shortest Path to Get All Keys - 865
๐ Smallest Subtree with all the Deepest Nodes - 866
๐ Prime Palindrome - 867
๐ Transpose Matrix - 868
๐ Binary Gap .swift - 869
๐ Reordered Power of 2 - 870
๐ Advantage Shuffle - 871
๐จ Minimum Number of Refueling Stops - 470
๐ Implement Rand10() Using Rand7()
Unit tests
This is a test-driven project. You may press โ + u in Xcode to invoke the tests. Or just rake
in CLI.
License
Copyright (C) 2018 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.