What are the common algorithms for LeetCode?

Free Coding Questions Catalog
Boost your coding skills with our essential coding questions catalog. Take a step towards a better tech career now!

LeetCode challenges cover a wide range of algorithmic concepts. Preparing for these challenges often involves familiarizing yourself with some common algorithms. Here's a list of key algorithms often encountered in LeetCode problems:

1. Sorting Algorithms

  • Bubble Sort
  • Merge Sort
  • Quick Sort
  • Heap Sort
  • Insertion Sort
  • Radix Sort
  • Binary Search
  • Depth-First Search (DFS)
  • Breadth-First Search (BFS)
  • Linear Search

3. Dynamic Programming

  • Memoization
  • Tabulation
  • Divide and Conquer

4. Recursion

  • Basic Recursion
  • Backtracking (e.g., solving puzzles like Sudoku, N-Queens problem)

5. Graph Algorithms

  • Dijkstra's Algorithm (Shortest Path)
  • Bellman-Ford Algorithm
  • Floyd-Warshall Algorithm
  • Topological Sort
  • Kruskal’s and Prim’s Algorithms (Minimum Spanning Tree)

6. Tree Algorithms

  • Tree Traversal (Inorder, Preorder, Postorder)
  • Binary Search Trees
  • AVL Trees
  • Segment Trees
  • Fenwick Trees or Binary Indexed Trees

7. Greedy Algorithms

  • Activity Selection
  • Huffman Coding
  • Prim’s and Kruskal’s Algorithms

8. String Manipulation Algorithms

  • String Matching and Parsing
  • KMP Algorithm (Knuth Morris Pratt)
  • Rabin-Karp Algorithm
  • Trie (Prefix Tree) Implementation

9. Bit Manipulation Techniques

  • Basic Bit Operations
  • Bitmasking Techniques
  • Brian Kernighan’s Algorithm

10. Data Structures

  • Arrays and Linked Lists
  • Stacks and Queues
  • Hash Tables
  • Heaps

Conclusion

This list is not exhaustive but covers many of the fundamental algorithms that are often used to solve problems on LeetCode. A solid understanding of these algorithms, along with strong problem-solving skills, will be immensely beneficial in tackling LeetCode challenges effectively.

TAGS
Data Structures and Algorithms
Dynamic Programming Patterns
Coding Interview Questions
Coding Interview
Coding Patterns
CONTRIBUTOR
Design Gurus Team
Explore Answers
Related Courses
Image
Grokking the Coding Interview: Patterns for Coding Questions
Image
Grokking Data Structures & Algorithms for Coding Interviews
Image
Grokking 75: Top Coding Interview Questions