Nov 24, 2025
Queues are one of the most versatile data structures in algorithm problems. This page collects ready-to-use C++ templates for every queue variant you’ll encounter on LeetCode — from the basic...
leetcodetemplatesqueue
Nov 24, 2025
This page collects ready-to-use C++ templates for bit manipulation, fast exponentiation, GCD/LCM, prime sieves, and basic number theory. Each snippet is self-contained — copy it into your solution and adapt...
leetcodetemplatesmathbit-manipulation
Nov 24, 2025
This page collects battle-tested Python templates for every major linked-list pattern you’ll see on LeetCode. Each section includes ready-to-use code, the signal phrases that tell you which pattern to reach...
leetcodetemplateslinked-list
Nov 24, 2025
Depth-First Search (DFS) is one of the most fundamental graph traversal algorithms. It works by starting at a node and exploring as far down each branch as possible before backtracking...
leetcodetemplatesdfsgraph
Nov 24, 2025
Data structure design problems are among the most popular interview questions at top tech companies. This page provides complete, tested C++ implementations for LRU/LFU cache, Trie, time-based key-value store, and...
leetcodetemplatesdesign
Nov 24, 2025
Breadth-First Search (BFS) is a graph traversal algorithm that explores nodes layer by layer, visiting all neighbors at the current depth before moving deeper. It’s the go-to technique for finding...
leetcodetemplatesbfsgraph
Nov 24, 2025
Welcome to the backtracking templates! Backtracking is one of the most versatile problem-solving techniques in competitive programming—once you learn the core pattern, you can tackle a huge family of problems...
leetcodetemplatesbacktracking
Nov 24, 2025
Welcome to the Array & Matrix template collection! These are ready-to-use C++ snippets for the most common array patterns: two pointers, sliding window, prefix sum, binary search, and matrix operations....
leetcodetemplatesarraymatrix
Nov 20, 2025
Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands.
leetcodealgorithmmediumcppdfsgraphmatrixproblem-solving
Nov 18, 2025
Given an array of integers arr, sort the array by performing a series of pancake flips.
leetcodealgorithmmediumcpparraysortingproblem-solving