1311. Algorithm - Problem List at LeetCodeAlgorithm and Leetcode
Problem List at LeetCode.
1. Array
- 1. Two Sum (HashMap)
- 167. Two Sum II - Input array is sorted (Two Pointers)
- 15. 3Sum (Sort + Loop + Two Pointers)
- 16. 3Sum Closest (Sort + Loop + Two Pointers + diff)
- 259. 3Sum Smaller (Sort + Loop + Two Pointers)
- 18. 4Sum (Sort + Double Loop + Two Pointers + HashSet)
- 653. Two Sum IV - Input is a BST (Tree, HashSet, Recursion)
- 169. Majority Element(n/2) (++, —)
- 229. Majority Element II(n/3) (Two Loops, 1st->Two candidates, 2nd->count)
- 243. Shortest Word Distance (One loop + Two variables for indexes)
- 244. Shortest Word Distance II (HashMap, map value=List)
- 245. Shortest Word Distance III
- 55. Jump Game (Greedy)
- 45. Jump Game II
- 54. Spiral Matrix (Four Directions)
- 59. Spiral Matrix II (Four Directions)
- 26. Remove Duplicates from Sorted Array(No Duplicated) (On variable for index)
- 80. Remove Duplicates from Sorted Array II(One Duplicated) (n > nums[i - 2])
- 27. Remove Element (Fast and slow pointers)
- 118. Pascal’s Triangle (Rolling, use the previous list create new list)
- 119. Pascal’s Triangle II (Rolling, from end to start)
- 120. Triangle(DP, Bottom Up or Top Down)
- 217. Contains Duplicate(HashSet, One Pass)
- 219. Contains Duplicate II(at most k distance)(HashSet, Sliding window)
- 220. Contains Duplicate III(distance and value)(SortedSet, !!!)
- 380. Insert Delete GetRandom O(1)(Design: HashMap+List)
- 381. Insert Delete GetRandom O(1) - Duplicates allowed(HashMap+TreeSet+List)
- 442. Find All Duplicates in an Array (Swap until nums[i] = i + 1)
- 448. Find All Numbers Disappeared in an Array (Swap until nums[i] = i + 1, return i + 1)
- 531. Lonely Pixel I (Two arrays for row and column, first count, second check)
- 533. Lonely Pixel II (HashMap + Array)
- 79. Word Search (DFS)(!!!)
- 212. Word Search II(Trie)
- 11. Container With Most Water (!!!!)
- 41. First Missing Positive (!!!)
- 268. Missing Number(Sum Formula)
- 66. Plus One
- 73. Set Matrix Zeroes(!!!)
- 74. Search a 2D Matrix
- 75. Sort Colors(!!!!)
- 189. Rotate Array (Three steps for rotation)
- 280. Wiggle Sort
- 283. Move Zeroes
- 48. Rotate Image
- 31. Next Permutation(!!!)
- 88. Merge Sorted Array
- 56. Merge Intervals
- 57. Insert Interval
- 4. Median of Two Sorted Arrays (!!!!)
- 34. Find First and Last Position of Element in Sorted Array(!!!!!)
- 128. Longest Consecutive Sequence(!!!!!)
- 162. Find Peak Element
- 209. Minimum Size Subarray Sum
- 228. Summary Ranges
- 238. Product of Array Except Self
- 277. Find the Celebrity
- 287. Find the Duplicate Number
- 289. Game of Life
- 370. Range Addition
- 414. Third Maximum Number
- 485. Max Consecutive Ones
- 532. K-diff Pairs in an Array
- 548. Split Array with Equal Sum(HashSet)
- 560. Subarray Sum Equals K
- 561. Array Partition I
- 562. Longest Line of Consecutive One in Matrix(DP)
- 565. Array Nesting(HashSet)
- 566. Reshape the Matrix
- 581. Shortest Unsorted Continuous Subarray
- 605. Can Place Flowers
- 611. Valid Triangle Number
- 621. Task Scheduler
- 624. Maximum Distance in Arrays
- 628. Maximum Product of Three Numbers
- 643. Maximum Average Subarray I
- 644. Maximum Average Subarray II
- 661. Image Smoother
- 665. Non-decreasing Array
- 667. Beautiful Arrangement II
- 670. Maximum Swap
- 674. Longest Continuous Increasing Subsequence
- 683. K Empty Slots
- 689. Maximum Sum of 3 Non-Overlapping Subarrays
- 695. Max Area of Island
- 697. Degree of an Array
- 713. Subarray Product Less Than K
- 715. Range Module
- 717. 1-bit and 2-bit Characters
- 723. Candy Crush
2. String
- 125. Valid Palindrome (Two Pointers)
- 680. Valid Palindrome II
- 242. Valid Anagram (Use Array as HashMap)
- 127. Word Ladder (HashSet + BFS)
- 126. Word Ladder II (HashSet + WordNode)(!!!!!)
- 72. Edit Distance(!!!!!)(DP)
- 161. One Edit Distance
- 3. Longest Substring Without Repeating Characters (HashMap + Two Pointers)
- 30. Substring with Concatenation of All Words
- 76. Minimum Window Substring (HashMap + Two Pointers)
- 159. Longest Substring with At Most Two Distinct Characters (HashMap + Two Pointers)
- 438. Find All Anagrams in a String
- 6. ZigZag Conversion
- 8. String to Integer (atoi)
- 12. Integer to Roman
- 13. Roman to Integer
- 14. Longest Common Prefix
- 17. Letter Combinations of a Phone Number
- 22. Generate Parentheses
- 28. Implement strStr()
- 38. Count and Say
- 43. Multiply Strings
- 49. Group Anagrams
- 58. Length of Last Word
- 65. Valid Number
- 67. Add Binary
- 157. Read N Characters Given Read4
- 158. Read N Characters Given Read4 II - Call multiple times
- 165. Compare Version Numbers
- 214. Shortest Palindrome
- 249. Group Shifted Strings
- 271. Encode and Decode Strings
- 273. Integer to English Words
- 293. Flip Game
- 336. Palindrome Pairs(Trie)
- 340. Longest Substring with At Most K Distinct Characters
- 383. Ransom Note
- 385. Mini Parser
- 387. First Unique Character in a String
- 434. Number of Segments in a String
- 443. String Compression
- 459. Repeated Substring Pattern
- 520. Detect Capital
- 537. Complex Number Multiplication
- 539. Minimum Time Difference
- 544. Output Contest Matches
- 551. Student Attendance Record I
- 553. Optimal Division
- 555. Split Concatenated Strings
- 564. Find the Closest Palindrome
- 583. Delete Operation for Two Strings
- 609. Find Duplicate File in System
- 616. Add Bold Tag in String
- 632. Smallest Range
- 635. Design Log Storage System
- 657. Judge Route Circle
- 681. Next Closest Time
- 686. Repeated String Match
- 696. Count Binary Substrings
- 709. To Lower Case
- 722. Remove Comments
- 736. Parse Lisp Expression
- 758. Bold Words in String
- 761. Special Binary String
- 767. Reorganize String
- 788. Rotated Digits
- 791. Custom Sort String
- 800. Similar RGB Color
- 804. Unique Morse Code Words
- 809. Expressive Words
- 816. Ambiguous Coordinates
- 819. Most Common Word
- 824. Goat Latin
- 831. Masking Personal Information(!!!)
- 842. Split Array into Fibonacci Sequence
- 848. Shifting Letters
- 856. Score of Parentheses
- 859. Buddy Strings
- 893. Groups of Special-Equivalent Strings
3. Subset
- 78. Subsets
- 90. Subsets II
- 46. Permutations (No pos, always from 0)
- 47. Permutations II (contains duplicates) (visited)
- 39. Combination Sum
- 40. Combination Sum II (can’t reuse same element)
- 216. Combination Sum III
- 377. Combination Sum IV(DP)
- 131. Palindrome Partitioning
- 132. Palindrome Partitioning II(DP)
4. LinkedList
- 206. Reverse Linked List
- 92. Reverse Linked List II
- 25. Reverse Nodes in k-Group
- 876. Middle of the Linked List(second middle node)
- 21. Merge Two Sorted Lists
- 23. Merge k Sorted Lists(Binary Merge, Heap)
- 83. Remove Duplicates from Sorted List
- 82. Remove Duplicates from Sorted List II
- 237. Delete Node in a Linked List
- 203. Remove Linked List Elements
- 19. Remove Nth Node From End of List (One pass, moving window)
- 138. Copy List with Random Pointer (Append Node, add random, split)
- 24. Swap Nodes in Pairs
- 61. Rotate List
- 86. Partition List
- 143. Reorder List
- 147. Insertion Sort List
- 148. Sort List (Merge Sort, nlog(n))
- 160. Intersection of Two Linked Lists
- 234. Palindrome Linked List
- 328. Odd Even Linked List
- 369. Plus One Linked List
- 370. Design Phone Directory(Design, HashSet+Queue)
- 430. Flatten a Multilevel Doubly Linked List
- 707. Design Linked List
- 708. Insert into a Cyclic Sorted List
- 725. Split Linked List in Parts
- 817. Linked List Components (HashSet)
5. Stack
- 20. Valid Parentheses(Stack, store the second one; extend pairs with HashMap)
- 678. Valid Parenthesis String(Multiple solution: String, Stack)
- 71. Simplify Path (Deque)
- 155. Min Stack (Two Stacks)
- 225. Implement Stack using Queues (Two Queues, all in first queue)
- 232. Implement Queue using Stacks (Two Stacks, new and old)
- 496. Next Greater Element I (Stack + HashMap; Extend to right/left and large/small)
- 503. Next Greater Element II
- 556. Next Greater Element III
- 84. Largest Rectangle in Histogram (!!!!!)
- 85. Maximal Rectangle (!!)(DP)
- 150. Evaluate Reverse Polish Notation (Stack)
- 316. Remove Duplicate Letters
- 341. Flatten Nested List Iterator
- 385. Mini Parser
- 394. Decode String
- 402. Remove K Digits
- 439. Ternary Expression Parser
- 456. 132 Pattern
- 591. Tag Validator
- 636. Exclusive Time of Functions
- 682. Baseball Game
- 726. Number of Atoms
- 735. Asteroid Collision
- 739. Daily Temperatures
- 844. Backspace String Compare
- 853. Car Fleet
- 856. Score of Parentheses
- 880. Decoded String at Index
- 895. Maximum Frequency Stack
6. Queue
- 346. Moving Average from Data Stream (Queue)
- 353. Design Snake Game (HashSet + Deque)
- 363. Max Sum of Rectangle No Larger Than K
- 582. Kill Process (Queue+Tree)
- 621. Task Scheduler
- 622. Design Circular Queue
- 641. Design Circular Deque
- 862. Shortest Subarray with Sum at Least K
7. Tree
- 94. Binary Tree Inorder Traversal (Recursion or Iteration)
- 144. Binary Tree Preorder Traversal (Recursion or Iteration)
- 145. Binary Tree Postorder Traversal (Recursion or Iteration)
- 102. Binary Tree Level Order Traversal (Iteration with Queue)
- 107. Binary Tree Level Order Traversal II (Iteration with Queue)
- 103. Binary Tree Zigzag Level Order Traversal (Iteration with Queue)
- 96. Unique Binary Search Trees(DP)
- 95. Unique Binary Search Trees II(Recursion)
- 297. Serialize and Deserialize Binary Tree (Queue !!!!!)
- 449. Serialize and Deserialize BST
- 536. Construct Binary Tree from String
- 606. Construct String from Binary Tree
- 105. Construct Binary Tree from Preorder and Inorder Traversal (Find root+recursion)
- 106. Construct Binary Tree from Inorder and Postorder Traversal (Find root+recursion)
- 899. Construct Binary Tree from Preorder and Postorder Traversal (Find root+recursion)
- 112. Path Sum (Recursion)
- 113. Path Sum II (Back tracking, similar to Subset)
- 437. Path Sum III (Recursion)
- 666. Path Sum IV (HashMap+DFS)
- 298. Binary Tree Longest Consecutive Sequence (Recursion)
- 549. Binary Tree Longest Consecutive Sequence II (Recursion + Global Variable)
- 428. Serialize and Deserialize N-ary Tree (Preorder, value + children count)
- 429. N-ary Tree Level Order Traversal (Queue)
- 431. Encode N-ary Tree to Binary Tree (Next Level -> left, Same Level -> right)
- 559. Maximum Depth of N-ary Tree (Recursion)
- 589. N-ary Tree Preorder Traversal (Stack)
- 590. N-ary Tree Postorder Traversal (Stack)
- 235. Lowest Common Ancestor of a Binary Search Tree (Comparison + Recursion)
- 236. Lowest Common Ancestor of a Binary Tree (Recursion + Comparision)
- 116. Populating Next Right Pointers in Each Node
- 117. Populating Next Right Pointers in Each Node II
- 104. Maximum Depth of Binary Tree (Recursion)
- 111. Minimum Depth of Binary Tree (Recursion)
- 98. Validate Binary Search Tree (Recursion with min and max at each level)
- 99. Recover Binary Search Tree
- 100. Same Tree (Recursion)(!!!!!)
- 101. Symmetric Tree (Recursion)(!!!)
- 110. Balanced Binary Tree (Recursion, help method returns -1)(!!!!)
- 617. Merge Two Binary Trees (Recursion)
- 124. Binary Tree Maximum Path Sum
- 129. Sum Root to Leaf Numbers
- 156. Binary Tree Upside Down
- 199. Binary Tree Right Side View
- 222. Count Complete Tree Nodes
- 226. Invert Binary Tree (Recursion)(!!!!!)
- 230. Kth Smallest Element in a BST
- 250. Count Univalue Subtrees
- 687. Longest Univalue Path
- 257. Binary Tree Paths
- 285. Inorder Successor in BST
- 333. Largest BST Subtree
- 366. Find Leaves of Binary Tree
- 404. Sum of Left Leaves
- 450. Delete Node in a BST
- 501. Find Mode in Binary Search Tree
- 508. Most Frequent Subtree Sum
- 513. Find Bottom Left Tree Value
- 515. Find Largest Value in Each Tree Row
- 538. Convert BST to Greater Tree
- 543. Diameter of Binary Tree
- 545. Boundary of Binary Tree
- 563. Binary Tree Tilt
- 572. Subtree of Another Tree
- 623. Add One Row to Tree
- 637. Average of Levels in Binary Tree
- 652. Find Duplicate Subtrees
- 654. Maximum Binary Tree
- 655. Print Binary Tree
- 662. Maximum Width of Binary Tree
- 663. Equal Tree Partition
- 669. Trim a Binary Search Tree(!!!!)
- 671. Second Minimum Node In a Binary Tree
- 700. Search in a Binary Search Tree
- 701. Insert into a Binary Search Tree
- 742. Closest Leaf in a Binary Tree
- 814. Binary Tree Pruning
- 834. Sum of Distances in Tree
- 863. All Nodes Distance K in Binary Tree
- 865. Smallest Subtree with all the Deepest Nodes
- 872. Leaf-Similar Trees
- 894. All Possible Full Binary Trees
- 108. Convert Sorted Array to Binary Search Tree
- 109. Convert Sorted List to Binary Search Tree
- 426. Convert Binary Search Tree to Sorted Doubly Linked List
- 173. Binary Search Tree Iterator
- 114. Flatten Binary Tree to Linked List
- 255. Verify Preorder Sequence in Binary Search Tree(Stack)
- 331. Verify Preorder Serialization of a Binary Tree(Stack)
Binary Indexed Tree/Fenwick-Tree
- https://leetcode.com/tag/binary-indexed-tree/
- https://www.geeksforgeeks.org/binary-indexed-tree-or-fenwick-tree-2/
8. Trie (Prefix Tree)
- 208. Implement Trie (Prefix Tree) (TrieNode=char+HashMap+isLeaf)
- 211. Add and Search Word - Data structure design (TireNode=String+Array, DFS)
- 421. Maximum XOR of Two Numbers in an Array (TrieNode= {TrieNode zero; TrieNode one;})
- 425. Word Squares (Trie + BackTracking)
- 472. Concatenated Words
- 642. Design Search Autocomplete System(!!!!!)
- 648. Replace Words (HashSet or Trie)
- 676. Implement Magic Dictionary
- 677. Map Sum Pairs
- 720. Longest Word in Dictionary
- 745. Prefix and Suffix Search
9. Bloom Filter
- https://www.youtube.com/watch?v=bEmBh1HtYrw
- https://www.youtube.com/watch?v=bgzUdBVr5tE
10. Segment Tree
- 307. Range Sum Query - Mutable (Fenwick Tree or Segment Tree)
- 308. Range Sum Query 2D - Mutable
- 315. Count of Smaller Numbers After Self
- 493. Reverse Pairs
- 699. Falling Squares
- 715. Range Module
11. Binary Search
- 35. Search Insert Position
- 153. Find Minimum in Rotated Sorted Array
- 154. Find Minimum in Rotated Sorted Array II (Brute Force, O(n))
12. Hash Table
- 729. My Calendar I (TreeMap)
- 731. My Calendar II
- 732. My Calendar III (TreeMap)
- 146. LRU Cache (DoublyLinkedList + HashMap)
13. Heap
- 215. Kth Largest Element in an Array
- 703. Kth Largest Element in a Stream
- 295. Find Median from Data Stream
- 218. The Skyline Problem(Queue)
- 239. Sliding Window Maximum
- 347. Top K Frequent Elements(!!!!!)
- 355. Design Twitter
- 358. Rearrange String k Distance Apart
- 373. Find K Pairs with Smallest Sums
- 378. Kth Smallest Element in a Sorted Matrix
- 451. Sort Characters By Frequency
- 502. IPO
- 659. Split Array into Consecutive Subsequences
- 692. Top K Frequent Words(PriorityQueue, Trie?)
- 719. Find K-th Smallest Pair Distance
- 743. Network Delay Time
- 759. Employee Free Time
- 767. Reorganize String
- 778. Swim in Rising Water
- 786. K-th Smallest Prime Fraction
- 787. Cheapest Flights Within K Stops
- 818. Race Car
- 857. Minimum Cost to Hire K Workers
- 864. Shortest Path to Get All Keys
- 871. Minimum Number of Refueling Stops
- 882. Reachable Nodes In Subdivided Graph
14. DP
- 62. Unique Paths (DP with Matrix, DP with array)
- 63. Unique Paths II (DP with Matrix, DP with array)
- 64. Minimum Path Sum (DP with Matrix, DP with array)
- 91. Decode Ways (DP with array)
- 639. Decode Ways II
- 70. Climbing Stairs (Recursion, DP, Fibonacci Number)
- 746. Min Cost Climbing Stairs (DP)
- 121. Best Time to Buy and Sell Stock (DP)
- 122. Best Time to Buy and Sell Stock II
- 123. Best Time to Buy and Sell Stock III (DP)
- 188. Best Time to Buy and Sell Stock IV
- 309. Best Time to Buy and Sell Stock with Cooldown
- 714. Best Time to Buy and Sell Stock with Transaction Fee(DP)
- 5. Longest Palindromic Substring(DP)
- 10. Regular Expression Matching
- 32. Longest Valid Parentheses
- 44. Wildcard Matching
- 53. Maximum Subarray(!!!!!)
- 87. Scramble String
- 97. Interleaving String
- 115. Distinct Subsequences
- 152. Maximum Product Subarray
- 174. Dungeon Game
- 221. Maximal Square
- 279. Perfect Squares
- 300. Longest Increasing Subsequence
- 312. Burst Balloons
- 321. Create Maximum Number
- 322. Coin Change
- 338. Counting Bits
- 343. Integer Break
- 351. Android Unlock Patterns
- 354. Russian Doll Envelopes
- 357. Count Numbers with Unique Digits
- 361. Bomb Enemy
- 363. Max Sum of Rectangle No Larger Than K
- 368. Largest Divisible Subset
- 375. Guess Number Higher or Lower II
- 376. Wiggle Subsequence
- 392. Is Subsequence
- 403. Frog Jump
- 410. Split Array Largest Sum
- 413. Arithmetic Slices
- 416. Partition Equal Subset Sum
- 418. Sentence Screen Fitting
- 446. Arithmetic Slices II - Subsequence
- 464. Can I Win
- 466. Count The Repetitions
- 467. Unique Substrings in Wraparound String
- 471. Encode String with Shortest Length
- 472. Concatenated Words
- 474. Ones and Zeroes
- 486. Predict the Winner
- 494. Target Sum
- 514. Freedom Trail
- 516. Longest Palindromic Subsequence
- 517. Super Washing Machines
- 523. Continuous Subarray Sum
- 546. Remove Boxes
- 568. Maximum Vacation Days
- 576. Out of Boundary Paths
- 600. Non-negative Integers without Consecutive Ones
- 629. K Inverse Pairs Array
- 638. Shopping Offers
- 646. Maximum Length of Pair Chain
- 647. Palindromic Substrings(DP)
- 656. Coin Path
- 664. Strange Printer
- 673. Number of Longest Increasing Subsequence
- 688. Knight Probability in Chessboard
- 689. Maximum Sum of 3 Non-Overlapping Subarrays
- 691. Stickers to Spell Word
- 698. Partition to K Equal Sum Subsets
- 712. Minimum ASCII Delete Sum for Two Strings
- 718. Maximum Length of Repeated Subarray(DP)
- 727. Minimum Window Subsequence
- 730. Count Different Palindromic Subsequences
- 740. Delete and Earn
- 741. Cherry Pickup
- 750. Number Of Corner Rectangles
- 764. Largest Plus Sign
- 787. Cheapest Flights Within K Stops
- 790. Domino and Tromino Tiling
- 801. Minimum Swaps To Make Sequences Increasing
- 808. Soup Servings
- 813. Largest Sum of Averages
- 818. Race Car
- 837. New 21 Game
- 838. Push Dominoes
- 847. Shortest Path Visiting All Nodes
- 871. Minimum Number of Refueling Stops
- 873. Length of Longest Fibonacci Subsequence
- 877. Stone Game
- 879. Profitable Schemes
- 887. Super Egg Drop
21. Facebook
- 34. Find First and Last Position of Element in Sorted Array(!!!!!)
- 285. Inorder Successor in BST
- 273. Integer to English Words
- 20. Valid Parentheses(Stack)
- Given two sparse Vectors, compute the Dot Product. careercup
- 67. Add Binary
- 286. Walls and Gates
- 236. Lowest Common Ancestor of a Binary Tree
- 301. Remove Invalid Parentheses
- 215. Kth Largest Element in an Array
- 98. Validate Binary Search Tree
- 76. Minimum Window Substring (HashMap + Two Pointers)
- 438. Find All Anagrams in a String
- 76. Minimum Window Substring-Discussion