Skip to content

Latest commit

 

History

History
473 lines (344 loc) · 31.1 KB

README.md

File metadata and controls

473 lines (344 loc) · 31.1 KB

Data Structures

Coding Patterns

Arrays

Two Pointers

K-Sum Problems

  1. Easy: 1. Two Sum
  2. Medium: 167. Two Sum II - Input Array Is Sorted
  3. Medium: 15. 3Sum
  4. Medium: 16. 3Sum Closest
  5. Medium: 259. 3Sum Smaller
  6. Medium: 1679. Max Number of K-Sum Pairs
  7. Medium: 532. K-diff Pairs in an Array

Palindrome Problems

  1. Easy: 9. Palindrome Number
  2. Easy: 125. Valid Palindrome
  3. Easy: 680. Valid Palindrome II

Miscellaneous Problems

  1. Easy: 283. Move Zeroes
  2. Easy: 392. Is Subsequence
  3. Easy: 977. Squares of a Sorted Array
  4. Medium: 11. Container with Most Water
  5. Medium: 75. Sort Colors
  6. Medium: 151. Reverse Words in a String
  7. Medium: 1438. Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit

Fast and Slow Pointers

  1. Easy: 141. Linked List Cycle
  2. Easy: 202. Happy Number
  3. Easy: 234. Palindrome Linked List
  4. Easy: 876. Middle of the Linked List
  5. Medium: 142. Linked List Cycle II
  6. Medium: 457. Circular Array Loop

Sliding Window

  1. Easy: 121. Best Time to Buy and Sell Stock
  2. Easy: 643. Maximum Average Subarray I
  3. Medium: 3. Longest Substring Without Repeating Characters
  4. Medium: 187. Repeated DNA Sequences
  5. Medium: 209. Minimum Size Subarray Sum
  6. Medium: 340. Longest Substring with At Most K Distinct Characters
  7. Medium: 395. Longest Substring with At Least K Repeating Characters
  8. Medium: 487. Max Consecutive Ones II
  9. Medium: 904. Fruit into Baskets
  10. Medium: 1004. Max Consecutive Ones III
  11. Medium: 1248. Count Number of Nice Subarrays
  12. Medium: 1456. Maximum Number of Vowels in a Substring of Given Length
  13. Medium: 1493. Longest Subarray of 1’s After Deleting One Element
  14. Hard: 30. Substring with Concatenation of All Words
  15. Hard: 76. Minimum Window Substring
  16. Hard: 239. Sliding Window Maximum
  17. Hard: 727. Minimum Window Subsequence
  18. Hard: 992. Subarrays with K Different Integers
  19. Hard: 1044. Longest Duplicate Substring

Merge Intervals

  1. Easy: 228. Summary Ranges
  2. Easy: 252. Meeting Rooms
  3. Easy: 2446. Determine if Two Events Have Conflict
  4. Medium: 56. Merge Intervals (Amberflo)
  5. Medium: 57. Insert Interval
  6. Medium: 253. Meeting Rooms II
  7. Medium: 435. Non-overlapping Intervals (Amberflo.io)
  8. Medium: 452. Minimum Number of Arrows to Burst Balloons
  9. Medium: 986. Interval List Intersections (H2O.ai)
  10. Medium: 1094. Car Pooling
  11. Medium: 1109. Corporate Flight Bookings
  12. Medium: 1229. Meeting Scheduler
  13. Medium: 1288. Remove Covered Intervals
  14. Medium: 2375. Construct Smallest Number From DI String
  15. Medium: 2406. Divide Intervals Into Minimum Number of Groups
  16. Medium: 2410. Maximum Matching of Players with Trainers
  17. Medium: 2462. Total Cost to Hire K Workers
  18. Medium: 2840. Check if Strings Can be Made Equal With Operations II
  19. Hard: 759. Employee Free Time
  20. Hard: 850. Rectangle Area II
  21. Hard: 1851. Minimum Interval to Include Each Query
  22. Hard: 2158. Amount of New Area Painted Each Day
  23. Hard: 2213. Longest Substring of One Repeating Character
  24. Hard: 2251. Number of Flowers in Full Bloom
  25. Hard: 2276. Count Integers in Intervals
  26. Hard: 2402. Meeting Rooms III

K-way Merge

  1. Easy: 88. Merge Sorted Array
  2. Medium: 373. Find K Pairs with Smallest Sums
  3. Medium: 378. Kth Smallest Element in a Sorted Matrix
  4. Hard: 4. Median of Two Sorted Arrays
  5. Hard: 23. Merge k Sorted Lists

Miscellaneous

  1. Easy: 1351. Count Negative Numbers in a Sorted Matrix

Stacks

  1. Easy: 20. Valid Parentheses
  2. Easy: 1047. Remove All Adjacent Duplicates in String
  3. Medium: 71. Simplify Path
  4. Medium: 150. Evaluate Reverse Polish Notation
  5. Medium: 227. Basic Calculator II
  6. Medium: 316. Remove Duplicate Letters
  7. Medium: 394. Decode String
  8. Medium: 402. Remove K Digits
  9. Medium: 456. 132 Pattern
  10. Medium: 503. Next Greater Element II
  11. Medium: 735. Asteroid Collision
  12. Medium: 739. Daily Temperatures
  13. Medium: 901. Online Stock Span
  14. Medium: 1249. Minimum Remove to Make Valid Parentheses
  15. Medium: 2390. Removing Stars From a String
  16. Hard: 84. Largest Rectangle in Histogram
  17. Hard: 224. Basic Calculator

Hash Maps

  1. Easy: 205. Isomorphic Strings
  2. Easy: 409. Longest Palindrome
  3. Easy: 496. Next Greater Element I
  4. Easy: 1207. Unique Number of Occurrences
  5. Easy: 2215. Find the Difference of Two Arrays
  6. Medium: 166. Fraction to Recurring Decimal
  7. Medium: 1657. Determine if Two Strings Are Close
  8. Medium: 2352. Equal Row and Column Pairs

Trees

Basics

  1. Easy: 100. Same Tree
  2. Easy: 101. Symmetric Tree
  3. Easy: 104. Maximum Depth of Binary Tree
  4. Easy: 110. Balanced Binary Tree
  5. Easy: 111. Minimum Depth of Binary Tree
  6. Easy: 226. Invert Binary Tree
  7. Easy: 257. Binary Tree Paths
  8. Easy: 543. Diameter of Binary Tree
  9. Easy: 572. Subtree of Another Tree
  10. Easy: 637. Average of Levels in Binary Tree
  11. Easy: 872. Leaf-Similar Trees

Graphs

Topological Sort

  1. Easy: 953. Verifying an Alien Dictionary
  2. Medium: 207. Course Schedule
  3. Medium: 210. Course Schedule II
  4. Medium: 2115. Find All Possible Recipes from Given Supplies
  5. Hard: 269. Alien Dictionary
  6. Hard: 1203. Sort Items by Groups Respecting Dependencies
  7. Hard: 1857. Largest Color Value in a Directed Graph

Union Find / Disjoint Set Union

Dijkstra’s

Minimum Spanning Tree

Custom Data Structures

  1. Easy: 359. Logger Rate Limiter

Bit Manipulation

XOR Applications

Finding Missing or Unique Numbers

  1. Easy: 136. Single Number
  2. Easy: 268. Missing Number
  3. Easy: 389. Find the Difference
  4. Medium: 137. Single Number II
  5. Medium: 260. Single Number III

XOR Optimization Problems

  1. Medium: 421. Maximum XOR of Two Numbers in an Array
  2. Medium: 1486. XOR Operation in an Array

Subarray XOR Problems

  1. Medium: 1877. XOR Queries of a Subarray
  2. Medium: 1915. Number of Wonderful Substrings
  3. Hard: 2565. Subsequence XOR Queries

Bit Counting

  1. Easy: 191. Number of 1 Bits
  2. Easy: 338. Counting Bits
  3. Easy: 762. Prime Number of Set Bits in Binary Representation
  4. Medium: 477. Total Hamming Distance

Bit Manipulation

Basic Operations

  1. Easy: 476. Number Complement
  2. Easy: 693. Binary Number with Alternating Bits
  3. Easy: 832. Flipping an Image
  4. Easy: 1009. Complement of Base 10 Integer
  5. Easy: 1342. Number of Steps to Reduce a Number to Zero
  6. Medium: 89. Gray Code

Bit Tricks

  1. Easy: 231. Power of Two
  2. Easy: 1356. Sort Integers by The Number of 1 Bits
  3. Medium: 1318. Minimum Flips to Make a OR b Equal to c

Bit Shifting

  1. Easy: 190. Reverse Bits
  2. Medium: 861. Score After Flipping Matrix

Bitwise AND Operations

  1. Medium: 201. Bitwise AND of Numbers Range
  2. Medium: 1529. Minimum Suffix Flips

Bit Masking

  1. Easy: 461. Hamming Distance
  2. Medium: 318. Maximum Product of Word Lengths
  3. Medium: 397. Integer Replacement
  4. Medium: 1461. Check If a String Contains All Binary Codes of Size K

Application Problems

  1. Easy: 401. Binary Watch
  2. Medium: 29. Divide Two Integers
  3. Medium: 371. Sum of Two Integers
  4. Medium: 388. Longest Absolute File Path
  5. Hard: 233. Number of Digit One

Modified Binary Search

Search in Array

  1. Easy: 35. Search Insert Position
  2. Easy: 704. Binary Search
  3. Easy: 744. Find Smallest Letter Greater Than Target
  4. Medium: 34. Find First and Last Position of Element in Sorted Array
  5. Medium: 436. Find Right Interval

Standard Search

  1. Easy: 278. First Bad Version
  2. Easy: 374. Guess Number Higher or Lower
  3. Medium: 74. Search a 2D Matrix
  4. Medium: 702. Search in a Sorted Array of Unknown Size

Math

  1. Easy: 69. Sqrt(x)
  2. Easy: 367. Valid Perfect Square
  3. Easy: 441. Arranging Coins

Tricky Invariant

  1. Medium: 275. H-Index II
  2. Medium: 540. Single Element in a Sorted Array
  3. Medium: 658. Find K Closest Elements
  4. Medium: 852. Peak Index in a Mountain Array

As a Tool

  1. Easy: 1099. Two Sum Less Than K
  2. Medium: 300. Longest Increasing Subsequence
  3. Medium: 1498. Number of Subsequences That Satisfy the Given Sum Condition

On Solution Space

  1. Medium: 875. Koko Eating Bananas
  2. Medium: 1011. Capacity To Ship Packages Within D Days
  3. Medium: 1283. Find the Smallest Divisor Given a Threshold

Greedy Techniques

Classic Greedy Problems

  1. Easy: 1005. Maximize Sum Of Array After K Negations
  2. Medium: 53. Maximum Subarray
  3. Medium: 621. Task Scheduler
  4. Medium: 678. Valid Parenthesis String
  5. Medium: 1055. Shortest Way to Form String
  6. Medium: 1846. Maximum Element After Decreasing and Rearranging

Interval & Scheduling Problems

  1. Easy: 455. Assign Cookies
  2. Medium: 763. Partition Labels
  3. Medium: 1029. Two City Scheduling
  4. Medium: 1353. Maximum Number of Events That Can Be Attended
  5. Hard: 632. Smallest Range Covering Elements from K Lists

Resource Allocation & Optimization

  1. Easy: 860. Lemonade Change
  2. Easy: 1710. Maximum Units on a Truck
  3. Medium: 134. Gas Station
  4. Medium: 881. Boats to Save People
  5. Hard: 1326. Minimum Number of Taps to Open to Water a Garden
  6. Hard: 2551. Put Marbles in Bags

Sequence Reconstruction

  1. Hard: 871. Minimum Number of Refueling Stops
  2. Medium: 948. Bag of Tokens
  3. Hard: 2054. Two Best Non-Overlapping Events

Path & Movement Optimization

  1. Medium: 45. Jump Game II
  2. Medium: 55. Jump Game
  3. Medium: 1888. Minimum Number of Flips to Make the Binary String Alternating

Ordering & Sorting-Based Decisions

  1. Medium: 406. Queue Reconstruction by Height
  2. Medium: 649. Dota2 Senate

Cost Minimization

  1. Medium: 1578. Minimum Time to Make Rope Colorful
  2. Hard: 135. Candy

Kadane’s Algorithm

  1. Medium: 918. Maximum Sum Circular Subarray

Backtracking

Subset and Combination Patterns

  1. Medium: 17. Letter Combinations of a Phone Number
  2. Medium: 39. Combination Sum
  3. Medium: 40. Combination Sum II
  4. Medium: 77. Combinations
  5. Medium: 78. Subsets
  6. Medium: 90. Subsets II
  7. Medium: 93. Restore IP Addresses
  8. Medium: 131. Palindrome Partitioning
  9. Medium: 216. Combination Sum III
  10. Medium: 254. Factor Combinations

Permutation Patterns

  1. Medium: 31. Next Permutation
  2. Medium: 46. Permutations
  3. Medium: 47. Permutations II
  4. Medium: 267. Palindrome Permutation II
  5. Medium: 320. Generalized Abbreviation
  6. Medium: 526. Beautiful Arrangement
  7. Medium: 784. Letter Case Permutation
  8. Hard: 425. Word Squares

Constraint Satisfaction / Target Building

  1. Medium: 22. Generate Parentheses
  2. Medium: 241. Different Ways to Add Parentheses
  3. Hard: 37. Sudoku Solver
  4. Hard: 44. Wildcard Matching
  5. Hard: 282. Expression Add Operators
  6. Hard: 301. Remove Invalid Parentheses

Pathfinding

  1. Medium: 79. Word Search
  2. Medium: 797. All Paths From Source to Target
  3. Medium: 1219. Path with Maximum Gold
  4. Medium: 490. The Maze
  5. Hard: 489. Robot Room Cleaner
  6. Hard: 980. Unique Paths III

Board Configuration

  1. Hard: 51. N-Queens
  2. Hard: 52. N-Queens II

Optimization / Packing

  1. Medium: 473. Matchsticks to Square
  2. Medium: 638. Shopping Offers

String Construction / Variants

  1. Hard: 132. Palindrome Partitioning II

Dynamic Programming

Basic Foundations

Pascal’s Triangle (Combinatorial DP)

  1. Easy: 118. Pascal’s Triangle
  2. Easy: 119. Pascal’s Triangle II

Fibonacci-Style DP

Basic Fibonacci Recurrence

  1. Easy: 509. Fibonacci Number
  2. Easy: 1137. N-th Tribonacci Number

Step-based Fibonacci Recurrence

  1. Easy: 70. Climbing Stairs
  2. Easy: 746. Min Cost Climbing Stairs

Robbery-style Subproblems (Non-adjacent Selection)

  1. Medium: 198. House Robber
  2. Medium: 213. House Robber II
  3. Medium: 740. Delete and Earn

General 1D DP

Linear Recurrence (Fibonacci-Style)

  1. Medium: 650. 2 Keys Keyboard
  2. Medium: 651. 4 Keys keyboard
  3. Medium: 790. Domino and Tromino Tiling
  4. Medium: 2466. Count Ways To Build Good Strings

Partitioning (Subset or Breakpoint Decisions)

  1. Medium: 91. Decode Ways
  2. Hard: 639. Decode Ways II
  3. Hard: 1416. Restore the Array

Interval-Based DP (Segmentation Problems)

  1. Medium: 983. Minimum Cost For Tickets
  2. Medium: 1024. Video Stitching
  3. Hard: 1259. Handshakes That Don’t Cross

Decision-Based DP (Knapsack-Style)

  1. Medium: 322. Coin Change
  2. Medium: 2140. Solving Questions with Brainpower
  3. Hard: 871. Minimum Number of Refueling Stops

Maximum Subarray/Sequence DP (Kadane’s or DP)

  1. Medium: 152. Maximum Product Subarray
  2. Medium: 1048. Longest String Chain
  3. Medium: 1567. Maximum Length of Subarray With Positive Product

Wiggle / Alternating Pattern DP

  1. Medium: 376. Wiggle Subsequence

Parentheses Matching DP

  1. Hard: 32. Longest Valid Parentheses

Water Trapping / Geometry-Based DP

  1. Hard: 42. Trapping Rain Water