Skip to content

A repository of LeetCode solutions in Python, organized by data structures and algorithms. The goal is to systematically catalog and manage solutions for better understanding and practice.

Notifications You must be signed in to change notification settings

xiancao2024/LeetCode-Cheat-Sheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LeetCode Cheat Sheet

This repository contains a categorized list of LeetCode problems, organized by problem-solving techniques. Use this cheat sheet as a quick reference for different problem types and corresponding LeetCode problems.

Categories

1. Heap/Sorting

Used for problems involving finding the k-th smallest/largest elements or sorting.

  • 215. Kth Largest Element in an Array
  • 347. Top K Frequent Elements
  • 378. Kth Smallest Element in a Sorted Matrix
  • 75. Sort Colors
  • Merge Intervals

2. Two Pointers (Linked Lists)

Involves problems where two pointers or a two-pointer technique is used to solve linked list problems.

  • 21. Merge Two Sorted Lists
  • 19. Remove Nth Node From End of List
  • Linked List Cycle
  • Intersection of Two Linked Lists
  • Reverse Linked List

Greedy Two-Pointer

Typically involves optimizing a value while managing two criteria simultaneously with a sorted array.

  • 948. Bag of Tokens
    • Characteristics: Maximization/Minimization, Sorted Input, Dynamic Adjustment, Resource Management.

3. Brute Force/Backtracking

Suitable for problems where constraints are small and brute force is fast enough.

  • Permutations
  • Subset
  • Letter Combinations of a Phone Number
  • Generate Parentheses
  • N-Queens

4. Dynamic Programming (Small Constraint Bounds)

Used when brute force is too slow, but constraints are small.

  • House Robber
  • Longest Increasing Subsequence
  • Unique Paths
  • Partition Equal Subset Sum
  • Longest Palindromic Substring

5. Prefix Sums

Deals with problems involving subarrays or substrings with sums or additive operations.

  • Subarray Sum Equals K
  • Find Pivot Index
  • Range Sum Query - Immutable
  • Maximum Sum of Two Non-Overlapping Subarrays
  • Continuous Subarray Sum

6. Sliding Window

Involves problems with subarrays or substrings where the sliding window technique is used but does not involve additive sums.

  • Minimum Size Subarray Sum
  • Longest Substring Without Repeating Characters
  • Sliding Window Maximum
  • Longest Repeating Character Replacement
  • Fruit Into Baskets

7. Binary Search (Monotonic Condition)

Used for problems involving calculating max/min with a monotonic condition.

  • Find Minimum in Rotated Sorted Array
  • Search in Rotated Sorted Array
  • Median of Two Sorted Arrays
  • Find Peak Element
  • H-Index II

8. Dynamic Programming (Non-Monotonic Condition)

For problems where dynamic programming is used to calculate max/min but without a monotonic condition.

  • Maximum Subarray
  • Coin Change
  • Longest Common Subsequence
  • Minimum Path Sum
  • Knapsack Problem

9. Dynamic Programming (Splittable Sub-Problems)

For problems that can be split into smaller sub-problems.

  • Climbing Stairs
  • Edit Distance
  • Fibonacci Number
  • 0/1 Knapsack
  • Longest Palindromic Subsequence

10. Greedy Algorithms

Used when a problem can be solved with a greedy approach to calculate the answer.

  • Jump Game
  • Gas Station
  • Candy
  • Best Time to Buy and Sell Stock II
  • Minimum Number of Arrows to Burst Balloons

11. Brute Force/Backtracking (Number of Ways)

For problems asking for the number of ways and brute force is efficient enough.

  • Combination Sum
  • Letter Combinations of a Phone Number
  • Palindrome Partitioning
  • Word Search
  • Combinations

12. Dynamic Programming (Asking for Number of Ways)

Used when asking for the number of ways and brute force is not efficient enough.

  • Unique Paths
  • Target Sum
  • Coin Change 2
  • Combination Sum IV
  • Number of Longest Increasing Subsequence

Usage

  • Browse Categories: Navigate through the categories to find problems related to specific techniques.
  • Review Problems: Each problem is listed with its LeetCode problem number and description.
  • Clone or Fork: Clone the repository to your local machine or fork it for your personal use.

Contribution

Contributions are welcome! If you have additional problems or improvements:

  1. Add the problem to the appropriate category.
  2. Update this README file with new problems and categories.
  3. Create a pull request with your changes.

License

This repository is licensed under the MIT License. See the LICENSE file for details.


Happy coding!

About

A repository of LeetCode solutions in Python, organized by data structures and algorithms. The goal is to systematically catalog and manage solutions for better understanding and practice.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages