Jun 25, 2026
So you’ve heard about LeetCode but aren’t sure where to start? Or maybe you’ve opened a problem, stared at it for 30 minutes, and closed the tab? You’re not alone...
guideleetcode
guideleetcodebeginnercompetitive-programminginterview-prep
Apr 22, 2026
Python 3 Guide
pythonguidereferencelearning
pythonguidelearning-pathreference
Apr 22, 2026
Python 3 Guide: Modern Features (3.8–3.13)
pythonguidemodern-featuresreference
pythonguidemodern-pythontyping
Apr 22, 2026
Python 3 Guide: Basics & Idioms
pythonguidebasicsreference
pythonguidebasicsidioms
Apr 22, 2026
[Medium] 1962. Remove Stones to Minimize the Total
leetcodemediumarraygreedyheap
leetcodemediumgreedymax-heappriority-queuesimulation
Apr 21, 2026
[Medium] 2952. Minimum Number of Coins to be Added
leetcodemediumarraygreedysorting
leetcodemediumgreedyarraysortingcoverage
Apr 21, 2026
[Medium] 2592. Maximize Greatness of an Array
leetcodemediumarraygreedysorting
leetcodemediumarraygreedysortingtwo-pointers
Apr 20, 2026
Given a positive integer n, you can add or subtract any power of 2 in one operation. Return the minimum number of operations to reduce n to 0.
leetcodemediumbit-manipulation
leetcodemediumbit-manipulationgreedybfsmath
Apr 19, 2026
[Medium] 2539. Count the Number of Good Subsequences
leetcodemediumstringcombinatoricsmathhash-map
leetcodemediumstringcombinatoricsfrequencymodular-arithmetichash-map
Apr 18, 2026
[Medium] 329. Longest Increasing Path in a Matrix
leetcodemediummatrixdynamic-programmingdfs
leetcodemediummatrixdfsmemoizationtopological-sortdag
Apr 18, 2026
Given an m x n binary matrix filled with '0's and '1's, find the largest square containing only '1's and return its area.
leetcodemediumdynamic-programming
leetcodemediumdynamic-programmingmatrixdp
Apr 17, 2026
Given an array of integers citations where citations[i] is the number of citations a researcher received for their i-th paper, return the researcher’s h-index.
leetcodemediumsorting
leetcodemediumarraysortingcounting-sortgreedy
Apr 16, 2026
Given the head of a singly linked list and two integers left and right where left <= right, reverse the nodes of the list from position left to position right...
leetcodemediumlinked-list
leetcodemediumlinked-listreversalpointer-manipulation
Apr 15, 2026
You are given two linked lists: list1 and list2 of sizes n and m respectively. Remove list1’s nodes from the a-th node to the b-th node (0-indexed), and put list2...
leetcodemediumlinked-list
leetcodemediumlinked-listpointer-manipulation
Apr 14, 2026
[Medium] 143. Reorder List
leetcodemediumlinked-listtwo-pointers
leetcodemediumlinked-listfast-slow-pointersreversemerge
Apr 13, 2026
You are given an array of events where events[i] = [startDay, endDay]. You can attend an event on any single day in the range [startDay, endDay]. You can only attend...
leetcodemediumgreedyheap
leetcodemediumgreedyheapsortingscheduling
Apr 12, 2026
Given an integer n, return a list of all possible full binary trees with n nodes. Each node has value 0. A full binary tree is a tree where every...
leetcodemediumtreerecursionmemoization
leetcodemediumtreerecursionmemoizationdp
Apr 11, 2026
Given an array nums, find two indices i and j (i != j) such that the digit sum of nums[i] equals the digit sum of nums[j], and return the maximum...
leetcodemediumhash-maparray
leetcodemediumhash-maparraygreedy
Apr 10, 2026
You are given a list of tasks to complete in order. Each day you can complete one task. After completing a task of type t, you must wait at least...
leetcodemediumhash-mapsimulation
leetcodemediumhash-mapsimulationgreedy
Apr 9, 2026
[Medium] 223. Rectangle Area
leetcodemediummathgeometry
leetcodemediummathgeometry
Apr 9, 2026
Given an integer array nums and an integer k, find the maximum sum among all subarrays of length k that have all distinct elements. Return 0 if no such subarray...
leetcodemediumsliding-windowhash-map
leetcodemediumsliding-windowhash-maparray
Apr 8, 2026
Given a singly linked list, return a random node’s value. Each node must have an equal probability of being chosen.
leetcodemediumlinked-listrandomized
leetcodemediumlinked-listrandomizedreservoir-sampling
Apr 7, 2026
Given a palindromic string palindrome, replace exactly one character to make it not a palindrome, and make the resulting string the lexicographically smallest possible. Return the result, or an empty...
leetcodemediumstringgreedy
leetcodemediumstringgreedy
Apr 6, 2026
You are given a 0-indexed integer array nums of length n. A split at index i is valid if the sum of the first i + 1 elements is greater...
leetcodemediumprefix-sumarray
leetcodemediumprefix-sumarray
Apr 5, 2026
You are given an integer array pref of size n. Find and return the array arr of size n that satisfies:
leetcodemediumbit-manipulationprefix
leetcodemediumbit-manipulationxorprefix
Apr 2, 2026
Given an m x n integer matrix, if an element is 0, set its entire row and column to 0. You must do it in place.
leetcodemediummatrixarray
leetcodemediummatrixarrayin-place
Apr 1, 2026
Given n nodes labeled 0 to n-1 and a list of undirected edges, determine if these edges form a valid tree.
leetcodemediumgraphdsudfs
leetcodemediumgraphdsudfstreecycle-detection
Mar 31, 2026
Given an integer array nums where exactly two elements appear once and all other elements appear exactly twice, find the two elements that appear only once. Return them in any...
leetcodemediumbit-manipulation
leetcodemediumbit-manipulationxor
Mar 30, 2026
You are given n train rides with distances dist[i]. Each train departs at an integer hour, so you must wait until the next whole hour to board the next train...
leetcodemediumbinary-search
leetcodemediumbinary-searchgreedy
Mar 29, 2026
Implement a thread-safe bounded blocking queue with the following methods: BoundedBlockingQueue(int capacity) – initialize with max capacity void enqueue(int element) – add element to the back; blocks if the queue...
leetcodemediumconcurrencydesign
leetcodemediumconcurrencydesignsemaphoreproducer-consumer
Mar 28, 2026
Two different threads will call foo and bar respectively. Design a mechanism so that "foobar" is printed n times by alternating between the two threads: foo always prints first, then...
leetcodemediumconcurrency
leetcodemediumconcurrencymutexcondition-variablemultithreading
Mar 27, 2026
Given an input string s, reverse the order of the words. A word is a sequence of non-space characters. Words are separated by at least one space. Return a string...
leetcodemediumstringtwo-pointers
leetcodemediumstringtwo-pointers
Mar 27, 2026
You are given two strings s and t. String t is generated by randomly shuffling s and then adding one more letter at a random position. Return the letter that...
leetcodeeasybit-manipulationstring
leetcodeeasybit-manipulationxorstringhash
Mar 27, 2026
Given two strings word1 and word2, merge them by adding letters in alternating order, starting with word1. If one string is longer, append the remaining letters at the end.
leetcodeeasystringtwo-pointers
leetcodeeasystringtwo-pointers
Mar 26, 2026
Given a string s representing a list of words, where each letter can be replaced by a group of letters inside braces {a,b,c}, return all possible words in sorted order....
leetcodemediumbacktrackingstring
leetcodemediumbacktrackingstringparsing
Mar 25, 2026
Given a circular integer array nums, find the maximum possible sum of a non-empty subarray. A circular subarray can wrap around the end back to the beginning.
leetcodemediumdparraykadane
leetcodemediumdparraykadane
Mar 24, 2026
You are given a nested list of integers nestedList. Each element is either an integer or a list whose elements may also be integers or other lists. Implement an iterator...
leetcodemediumdesignstackiterator
leetcodemediumdesignstackiterator
Mar 23, 2026
[Medium] 931. Minimum Falling Path Sum
leetcodemediumdpmatrix
leetcodemediumdynamic-programmingmatrix
Mar 22, 2026
There are n gas stations along a circular route. Station i has gas[i] units of gas. It costs cost[i] units to travel from station i to station i+1. Starting with...
leetcodemediumgreedyarray
leetcodemediumgreedyarray
Mar 21, 2026
Given an array of positive integers nums and an integer k, return the number of contiguous subarrays where the product of all elements is strictly less than k.
leetcodemediumsliding-windowtwo-pointers
leetcodemediumsliding-windowtwo-pointersarray
Mar 20, 2026
You are given an array prices where prices[i] is the price of a stock on day i. Find the maximum profit with as many transactions as you like, subject to:...
leetcodemediumdp
leetcodemediumdpstate-machinestock
Mar 19, 2026
[Medium] 362. Design Hit Counter
leetcodemediumdesignqueuesliding-window
leetcodemediumdesigndequesliding-window
Mar 19, 2026
In an infinite chess board with coordinates from -infinity to +infinity, a knight starts at (0, 0). Return the minimum number of moves to reach (x, y).
leetcodemediumbfs
leetcodemediumbfschessshortest-path
Mar 19, 2026
Implement a SnapshotArray that supports: SnapshotArray(int length) – initializes an array of the given length (all zeros) void set(index, val) – sets the element at index to val int snap()...
leetcodemediumdesignbinary-search
leetcodemediumdesignbinary-searchmap
Mar 18, 2026
Given a binary tree, a node X is good if there is no node with a value greater than X on the path from root to X. Return the number...
leetcodemediumtreedfsbfs
leetcodemediumtreedfsbfs
Mar 17, 2026
A company has n employees numbered 0 to n-1. Each employee has exactly one direct manager given in manager[i], except the head of the company (manager[headID] == -1). An employee...
leetcodemediumtreedfsbfs
leetcodemediumtreedfsbfsgraph
Mar 16, 2026
You are given a 2D array intervals where intervals[i] = [left_i, right_i] represents the inclusive interval [left_i, right_i]. Divide the intervals into one or more groups such that no two...
leetcodemediumgreedyheapintervals
leetcodemediumgreedyheapintervalssweep-line
Mar 15, 2026
A gene string is represented by an 8-character string of 'A', 'C', 'G', and 'T'. Given startGene, endGene, and a bank of valid gene strings, return the minimum number of...
leetcodemediumbfsstring
leetcodemediumbfsstringshortest-path
Mar 14, 2026
[Medium] 365. Water and Jug Problem
leetcodemediummathnumber-theory
leetcodemediumgcdbezout
Mar 12, 2026
[Medium] 797. All Paths From Source to Target
leetcodemediumgraphdfsbacktracking
leetcodemediumgraphdfsbacktracking
Mar 12, 2026
There are n rooms labeled 0 to n-1. All rooms are locked except room 0. Each room contains a set of keys to other rooms. Given rooms[i] – the set...
leetcodemediumgraphdfsbfs
leetcodemediumgraphdfsbfsreachability
Mar 11, 2026
Given an n x n binary matrix grid, return the length of the shortest clear path from top-left (0,0) to bottom-right (n-1,n-1). A clear path consists of cells with value...
leetcodemediumgraphbfs
leetcodemediumgraphbfsgridshortest-path
Mar 10, 2026
There are n computers numbered 0 to n-1 connected by cables. connections[i] = [a, b] means a cable connects computers a and b. You can remove an existing cable and...
leetcodemediumgraphdsu
leetcodemediumgraphdsuunion-findconnectivity
Mar 10, 2026
Given the head of a singly linked list, return the middle node. If there are two middle nodes, return the second middle node.
leetcodeeasylinked-listtwo-pointers
leetcodeeasylinked-listtwo-pointersslow-fast
Mar 9, 2026
You are given a string s and an array of index pairs pairs where pairs[i] = [a, b] indicates you can swap the characters at indices a and b any...
leetcodemediumstringgraphdsu
leetcodemediumstringgraphdsuunion-findsorting
Mar 8, 2026
You are given an array points where points[i] = [xi, yi] represents a point on the 2D plane. The cost to connect two points is the Manhattan distance: |xi -...
leetcodemediumgraphmstdsu
leetcodemediumgraphmstkruskaldsu
Mar 7, 2026
We can “shift” a string by shifting each character to its successive character (with z wrapping to a). For example, "abc" can be shifted to "bcd", …, "xyz", "yza", "zab"....
leetcodemediumstringhash
leetcodemediumstringhashcanonical-form
Mar 7, 2026
Given two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine. Each letter in magazine can only be used once.
leetcodeeasystringhash
leetcodeeasystringhashfrequency-count
Mar 7, 2026
Given two strings s and t, return true if t is an anagram of s, and false otherwise. An anagram uses the exact same characters with the exact same frequencies....
leetcodeeasystringhash
leetcodeeasystringhashsorting
Mar 7, 2026
Given an integer array nums and an integer k, return true if there are two distinct indices i and j such that nums[i] == nums[j] and abs(i - j) <=...
leetcodeeasyarrayhashsliding-window
leetcodeeasyarrayhashsliding-window
Mar 7, 2026
Given an integer array nums, return true if any value appears at least twice, and false if every element is distinct.
leetcodeeasyarrayhash
leetcodeeasyarrayhashsorting
Mar 6, 2026
Given the root of a binary tree and an integer targetSum, return all root-to-leaf paths where the sum of the node values equals targetSum. Each path should be returned as...
leetcodemediumtreedfsbacktracking
leetcodemediumtreedfsbacktracking
Mar 6, 2026
Given the root of a binary tree, return the inorder traversal of its nodes’ values. Inorder visits: left → root → right.
leetcodeeasytreedfs
leetcodeeasytreedfsstackmorris
Mar 6, 2026
Given the root of a binary tree, return the length of the diameter of the tree. The diameter is the length of the longest path between any two nodes (measured...
leetcodeeasytreedfs
leetcodeeasytreedfsrecursion
Mar 6, 2026
Given the root of a binary tree, return the postorder traversal of its nodes’ values. Postorder visits: left → right → root.
leetcodeeasytreedfs
leetcodeeasytreedfsstack
Mar 6, 2026
Given the root of a binary tree, return the preorder traversal of its nodes’ values. Preorder visits: root → left → right.
leetcodeeasytreedfs
leetcodeeasytreedfsstackmorris
Mar 6, 2026
Given the root of a binary tree and an integer targetSum, return true if the tree has a root-to-leaf path such that adding up all the values along the path...
leetcodeeasytreedfs
leetcodeeasytreedfsrecursion
Mar 6, 2026
Given a binary tree, determine if it is height-balanced. A height-balanced binary tree is one in which the depth of the two subtrees of every node never differs by more...
leetcodeeasytreedfs
leetcodeeasytreedfsrecursion
Mar 5, 2026
Given an integer array nums of unique elements, return all possible subsets (the power set). The solution must not contain duplicate subsets.
leetcodemediumbacktracking
leetcodemediumbacktrackingdfsbit-manipulation
Mar 4, 2026
Given an integer array nums and an integer k, return true if nums has a good subarray, i.e., a contiguous subarray of length at least 2 whose sum is a...
leetcodemediumprefix-sumhash
leetcodemediumprefix-sumhashmath
Mar 3, 2026
[Medium] 208. Implement Trie (Prefix Tree)
leetcodemediumtriedata-structure
leetcodemediumtrieprefix-treedesign
Mar 3, 2026
[Medium] 1804. Implement Trie II (Prefix Tree)
leetcodemediumtriedata-structure
leetcodemediumtrieprefix-treedesign
Mar 3, 2026
[Medium] 1344. Angle Between Hands of a Clock
leetcodemediummathgeometry
leetcodemediummathgeometrysimulation
Mar 3, 2026
[Easy] 1275. Find Winner on a Tic Tac Toe Game
leetcodeeasyarraysimulation
leetcodeeasyarraysimulationgame
Mar 2, 2026
[Medium] 621. Task Scheduler
leetcodemediumgreedycounting
leetcodemediumarraygreedycountingscheduling
Mar 2, 2026
[Hard] 358. Rearrange String k Distance Apart
leetcodehardstringheapgreedy
leetcodehardstringheapgreedyscheduling
Mar 1, 2026
[Medium] 80. Remove Duplicates from Sorted Array II
leetcodemediumarraytwo-pointers
leetcodemediumarraytwo-pointersin-place
Feb 28, 2026
[Medium] 61. Rotate List
leetcodemediumlinked-listpython
leetcodemediumlinked-listtwo-pointers
Feb 27, 2026
[Medium] 187. Repeated DNA Sequences
leetcodemediumstringhashingsliding-windowbit-manipulation
leetcodemediumstringhashingsliding-windowbit-manipulation
Feb 18, 2026
Given a positive integer n, generate an n × n matrix filled with elements from 1 to n² in spiral order (clockwise).
leetcodemediummatrixsimulation
leetcodemediummatrixsimulationspiral
Feb 17, 2026
Given two non-negative integers represented as strings num1 and num2, return their product as a string. You cannot convert the inputs to integers directly (numbers can be very large).
leetcodemediumstringmathsimulation
leetcodemediumstringmathbig-integersimulation
Feb 17, 2026
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.
leetcodehardtwo-pointersstackdp
leetcodehardtwo-pointersmonotonic-stackprefix-suffixdp
Feb 16, 2026
The count-and-say sequence is a sequence of digit strings defined by the recursive formula:
leetcodemediumstringsimulation
leetcodemediumstringsimulationrun-length-encoding
Feb 15, 2026
You are given an array of k linked lists, each sorted in ascending order. Merge all the linked lists into one sorted linked list and return it.
leetcodehardlinked-listdivide-and-conquerheap
leetcodehardlinked-listdivide-and-conquerheapmerge
Feb 15, 2026
Two strings are special-equivalent if you can swap characters at even indices among themselves and swap characters at odd indices among themselves, any number of times. Return the number of...
leetcodeeasystringhash
leetcodeeasystringhashcanonical-form
Feb 14, 2026
Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:
leetcodemediummathbit-manipulation
leetcodemediumbitmaskgridhash
Feb 14, 2026
Given two integers dividend and divisor, divide two integers without using multiplication, division, and mod operator. Return the quotient after dividing dividend by divisor. The integer division should truncate toward...
leetcodemediummathbit-manipulation
leetcodemediumbit-manipulationmath
Feb 12, 2026
Problem
leetcodemediumsliding-windowmonotonic-queue
leetcodemediumsliding-windowmonotonic-queue
Feb 11, 2026
Given an integer array nums, return true if you can partition the array into two subsets such that the sum of the elements in both subsets is equal or false...
leetcodemediumdynamic-programming
leetcodemediumdpknapsack
Feb 11, 2026
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.
leetcodemediumstack
leetcodemediumstackdata-structure-design
Feb 10, 2026
There is a dungeon with n x m rooms arranged as a grid.
leetcodemediumgraphshortest-pathdijkstragrid
leetcodemediumgraphshortest-pathdijkstragrid
Feb 10, 2026
There is a dungeon with n x m rooms arranged as a grid.
leetcodemediumgraphshortest-pathdijkstragrid
leetcodemediumgraphshortest-pathdijkstragrid
Feb 9, 2026
A message containing letters from A-Z can be encoded into numbers using the following mapping:
leetcodemediumdynamic-programming
leetcodemediumdynamic-programmingstring
Feb 9, 2026
There are n people standing in a queue numbered from 0 to n - 1 from left to right. You are given an array heights of distinct integers where heights[i]...
leetcodehardstackmonotonic-stack
leetcodehardstackmonotonic-stack
Feb 8, 2026
There exists an undirected tree with n nodes numbered 0 to n-1. You are given a 2D integer array edges of length n-1, where edges[i] = [ui, vi, lengthi] indicates...
leetcodemediumgraphshortest-pathdijkstra
leetcodemediumgraphshortest-pathdijkstra
Feb 8, 2026
You have numCourses courses labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] means you must take course bi before course...
leetcodemediumgraphtopological-sort
leetcodemediumgraphtopological-sort
Feb 7, 2026
You have infinitely many lakes, all initially empty. When it rains on lake n, that lake becomes full. If it rains on a lake that is already full, a flood...
leetcodemediumarraygreedybinary-searchset
leetcodemediumarraygreedybinary-searchset
Feb 6, 2026
Koko has n piles of bananas; the i-th pile has piles[i] bananas. The guards return in h hours. Koko can choose an integer eating speed k (bananas per hour). Each...
leetcodemediumarraybinary-search
leetcodemediumarraybinary-search
Feb 6, 2026
Given an array of integers nums and an integer k, return the number of unique k-diff pairs in the array.
leetcodemediumarrayhash-table
leetcodemediumarrayhash-table
Feb 6, 2026
You are given an integer eventTime (the event runs from time 0 to eventTime) and two arrays startTime and endTime representing n non-overlapping meetings. You may reschedule at most k...
leetcodemediumarrayintervalssliding-windowprefix-sum
leetcodemediumarrayintervalssliding-windowprefix-sum
Feb 6, 2026
Given an array of meeting time intervals where intervals[i] = [starti, endi], determine if a person could attend all meetings.
leetcodeeasyarraysortingintervals
leetcodeeasyarraysortingintervals
Feb 5, 2026
There are n flights labeled from 1 to n. You are given an array of flight bookings where bookings[i] = [firsti, lasti, seatsi] represents a booking for flights firsti through...
leetcodemediumarrayprefix-sumdifference-array
leetcodemediumarrayprefix-sumdifference-array
Feb 4, 2026
There are n cities connected by some number of flights. You are given an array flights where flights[i] = [fromi, toi, pricei] indicates that there is a flight from city...
leetcodemediumgraphshortest-pathdynamic-programmingbellman-ford
leetcodemediumgraphshortest-pathdynamic-programmingbellman-ford
Feb 3, 2026
You are given a network of n nodes, labeled from 1 to n. You are also given times, a list of travel times as directed edges times[i] = (ui, vi,...
leetcodemediumgraphshortest-pathdijkstra
leetcodemediumgraphshortest-pathdijkstra
Feb 2, 2026
Given an integer array nums and an integer k, return the number of non-empty subarrays that have a sum divisible by k.
leetcodemediumarrayhash-tableprefix-sum
leetcodemediumarrayhash-tableprefix-sum
Feb 2, 2026
This is an interactive problem.
leetcodehardarraystringinteractiveminmax
leetcodehardarraystringinteractiveminmax
Feb 1, 2026
Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k.
leetcodemediumarrayhash-tableprefix-sum
leetcodemediumarrayhash-tableprefix-sum
Feb 1, 2026
Given an integer array nums and an integer k, return the maximum length of a subarray that sums to k. If there is no such subarray, return 0.
leetcodemediumarrayhash-tableprefix-sum
leetcodemediumarrayhash-tableprefix-sum
Feb 1, 2026
Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*' where:
leetcodehardstringdynamic-programminggreedytwo-pointers
leetcodehardstringdynamic-programminggreedytwo-pointers
Jan 30, 2026
Design a time-based key-value data structure that can store multiple values for the same key at different timestamps and retrieve the key’s value at a certain timestamp.
leetcodemediumhash-tablebinary-searchdesign
leetcodemediumhash-tablebinary-searchdesign
Jan 30, 2026
Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value.
leetcodemediumarraybinary-search
leetcodemediumarraybinary-search
Jan 30, 2026
A peak element is an element that is strictly greater than its neighbors.
leetcodemediumarraybinary-search
leetcodemediumarraybinary-search
Jan 30, 2026
Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it...
leetcodeeasyarraybinary-search
leetcodeeasyarraybinary-search
Jan 29, 2026
Given an array of integers temperatures representing the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the i-th day...
leetcodemediumarraystackmonotonic-stack
leetcodemediumarraystackmonotonic-stack
Jan 28, 2026
Design a data structure that can query the frequency of a given value in a given subarray.
leetcodemediumarrayhash-mapbinary-searchdesign
leetcodemediumarrayhash-mapbinary-searchdesign
Jan 27, 2026
Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i].
leetcodemediumarrayprefix-sumtwo-pointers
leetcodemediumarrayprefix-sumtwo-pointers
Jan 27, 2026
You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given an array relations where relations[i] = [prevCoursei, nextCoursei],...
leetcodehardgraphtopological-sortdfsdynamic-programming
leetcodehardgraphtopological-sortdfsdynamic-programmingmemoization
Jan 26, 2026
Given an array of positive integers nums and a positive integer target, return the minimal length of a subarray whose sum is greater than or equal to target. If there...
leetcodemediumarraysliding-windowbinary-searchprefix-sum
leetcodemediumarraysliding-windowbinary-searchprefix-sumtwo-pointers
Jan 26, 2026
Given an integer array nums and an integer k, return the length of the shortest non-empty subarray of nums with a sum of at least k. If there is no...
leetcodehardarraysliding-windowdequeprefix-summonotonic-deque
leetcodehardarraysliding-windowdequeprefix-summonotonic-deque
Jan 26, 2026
Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The order of the elements may be changed. Then return the number of...
leetcodeeasyarraytwo-pointers
leetcodeeasyarraytwo-pointersin-place
Jan 25, 2026
You are given a 2D array of integers envelopes where envelopes[i] = [wi, hi] represents the width and the height of an envelope.
leetcodemediumarraydynamic-programmingbinary-searchsorting
leetcodemediumarraydynamic-programmingbinary-searchsortinglongest-increasing-subsequence
Jan 25, 2026
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a...
leetcodemediumarraydynamic-programming
leetcodemediumarraydynamic-programmingdpcircular-array
Jan 24, 2026
Design your implementation of the circular queue. The circular queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and...
leetcodemediumarraylinked-listdesignqueue
leetcodemediumarraylinked-listdesignqueuecircular-queuedata-structure
Jan 23, 2026
Given a list of folders folder, return the folders after removing all sub-folders in those folders. You may return the answer in any order.
leetcodemediumarraystringtriesorting
leetcodemediumarraystringtriesortingprefix-matching
Jan 22, 2026
You are given a 2D integer array orders, where orders[i] = [price_i, amount_i, orderType_i] denotes that amount_i orders have been placed of type orderType_i at price price_i. The orderType_i is:...
leetcodemediumarrayheappriority-queuesimulation
leetcodemediumarrayheappriority-queuesimulationgreedy
Jan 21, 2026
You are given an m x n integer array grid. There is a robot initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right...
leetcodemediumarraydynamic-programmingmatrix
leetcodemediumarraydynamic-programmingmatrixgridobstacles
Jan 20, 2026
Given an m x n matrix mat, return an array of all the elements of the matrix in a diagonal order.
leetcodemediumarraymatrixsimulation
leetcodemediumarraymatrixsimulation
Jan 20, 2026
Given an integer array nums, rotate the array to the right by k steps, where k is non-negative.
leetcodemediumarray
leetcodemediumarrayrotationtwo-pointers
Jan 20, 2026
This page collects ready-to-use C++ templates for every major binary search pattern you’ll encounter on LeetCode — from basic sorted-array lookup to rotated arrays, 2D matrices, and “search on the...
leetcodetemplatessearchbinary-search
leetcodetemplatessearchbinary-searchdivide-and-conquer
Jan 20, 2026
Given an integer array nums and two integers lower and upper, return the number of range sums that lie in [lower, upper] inclusive.
leetcodehardarraydivide-and-conquer
leetcodehardarraydivide-and-conquermerge-sortsegment-treeprefix-sum
Jan 19, 2026
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.
leetcodemediumtreedfs
leetcodemediumtreedfsrecursionlca
Jan 19, 2026
Design a data structure that supports adding new words and finding if a string matches any previously added string.
leetcodemediumstringdesigntrie
leetcodemediumstringdesigntriewildcard-searchdfs
Jan 19, 2026
There is a restaurant with a single chef. You are given an array customers, where customers[i] = [arrival_i, time_i]:
leetcodemediumarraysimulation
leetcodemediumarraysimulationgreedy
Jan 19, 2026
You have a set of integers s, which originally contains all the numbers from 1 to n. Unfortunately, due to some error, one of the numbers in s got duplicated...
leetcodeeasyarrayhash-tablemath
leetcodeeasyarrayhash-tablemathbit-manipulationnegative-marking
Jan 19, 2026
Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters.
leetcodeeasystringhash-tablegreedy
leetcodeeasystringhash-tablegreedybit-manipulationpalindrome
Jan 19, 2026
Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1.
leetcodeeasystringhash-table
leetcodeeasystringhash-tablebit-manipulationfrequency-counting
Jan 19, 2026
Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique and you may return the result in any order....
leetcodeeasyarrayhash-table
leetcodeeasyarrayhash-tabletwo-pointerssorting
Jan 19, 2026
Given the root of a binary tree, invert the tree, and return its root.
leetcodeeasytreedfs
leetcodeeasytreedfsrecursion
Jan 19, 2026
You are given an array of strings words and a string pref.
leetcodeeasystringarray
leetcodeeasystringarrayprefixsimulation
Jan 19, 2026
Given a string s, return the length of the longest substring between two equal characters, excluding the two equal characters themselves. If no such substring exists, return -1.
leetcodeeasystringhash-table
leetcodeeasystringhash-tablesubstringtwo-pointers
Jan 19, 2026
Given the root of a binary tree and an integer targetSum, return true if the tree has a root-to-leaf path such that adding up all the values along the path...
leetcodeeasytreedfs
leetcodeeasytreedfsrecursionbacktracking
Jan 19, 2026
Given a binary tree, find its minimum depth.
leetcodeeasytreedfs
leetcodeeasytreedfsbfsrecursion
Jan 19, 2026
Given the root of a binary tree, return its maximum depth — the number of nodes along the longest path from the root down to the farthest leaf.
leetcodeeasytreedfs
leetcodeeasytreedfsbfsrecursion
Jan 19, 2026
Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).
leetcodeeasytreedfs
leetcodeeasytreedfsrecursion
Jan 19, 2026
Given the roots of two binary trees p and q, write a function to check if they are the same or not.
leetcodeeasytreedfs
leetcodeeasytreedfsrecursion
Jan 19, 2026
Design a data structure that supports adding new words and finding if a string matches any previously added string.
leetcodemediumstringdesigntrie
leetcodemediumstringdesigntriewildcard-searchdfs
Jan 19, 2026
Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters.
leetcodeeasystringhash-tablegreedy
leetcodeeasystringhash-tablegreedybit-manipulationpalindrome
Jan 18, 2026
A trie (pronounced as “try”) or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of...
leetcodemediumstringdesigntrie
leetcodemediumstringdesigntrieprefix-treedata-structure
Jan 18, 2026
A k-booking happens when k events have some non-empty intersection (i.e., there is some time that is common to all k events).
leetcodehardarraybinary-searchdesignsegment-treeordered-set
leetcodehardarraybinary-searchdesignsegment-treelazy-propagationsweep-linedifference-array
Jan 18, 2026
You are given a string s. The score of a string is defined as the sum of the absolute difference between the ASCII values of adjacent characters.
leetcodeeasystringarray
leetcodeeasystringarraysimulationascii
Jan 17, 2026
You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a double booking.
leetcodemediumarraybinary-searchdesignordered-set
leetcodemediumarraybinary-searchdesignordered-setintervaloverlap-detection
Jan 17, 2026
You are given an integer array nums and you have to return a new array counts. The array counts has the property where counts[i] is the number of smaller elements...
leetcodehardarraybinary-searchdivide-and-conquerbinary-indexed-treesegment-treemerge-sort
leetcodehardarrayfenwick-treebinary-indexed-treecoordinate-compressioninversion-count
Jan 16, 2026
You are given two integer arrays fruits and baskets.
leetcodemediumarraygreedysegment-tree
leetcodemediumarraygreedysegment-treedata-structure
Jan 16, 2026
Given an integer array nums, handle multiple queries of the following types:
leetcodemediumarraysegment-treebinary-indexed-tree
leetcodemediumarraysegment-treebinary-indexed-treedata-structure
Jan 16, 2026
You are given an empty 2D binary grid grid of size m x n. The grid represents a map where 0’s represent water and 1’s represent land. Initially, all the...
leetcodehardarrayunion-findgraph
leetcodehardarrayunion-finddisjoint-setincrementaldynamic
Jan 15, 2026
There is a directed graph of n nodes with each node labeled from 0 to n - 1. The graph is represented by a 0-indexed 2D integer array graph where...
leetcodemediumgraphdfscycle-detection
leetcodemediumgraphdfscycle-detectionthree-state-coloring
Jan 15, 2026
You are given an integer array nums and you have to return a new array counts. The array counts has the property where counts[i] is the number of smaller elements...
leetcodehardarraybinary-searchdivide-and-conquerbinary-indexed-treesegment-treemerge-sort
leetcodehardarrayfenwick-treebinary-indexed-treecoordinate-compressioninversion-count
Jan 14, 2026
LCR 113. Course Schedule II
leetcodemediumgraphtopological-sortdfs
leetcodemediumgraphtopological-sortdfscycle-detection
Jan 14, 2026
A tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any connected graph without simple cycles is a tree.
leetcodemediumgraphtreetopological-sortbfs
leetcodemediumgraphtreetopological-sortbfspeeling-leaves
Jan 14, 2026
There is a new alien language that uses the English alphabet. However, the order among the letters is unknown to you.
leetcodehardgraphtopological-sortstring
leetcodehardgraphtopological-sortstringbfskahn
Jan 13, 2026
Design a queue that supports push and pop operations in the front, middle, and back.
leetcodemediumdesigndequedata-structure
leetcodemediumdesigndequedata-structuretwo-deques
Jan 12, 2026
Given an m x n grid of characters board and a string word, return true if word exists in the grid.
leetcodemediumarraybacktrackingmatrixdfs
leetcodemediumarraybacktrackingmatrixdfsrecursion
Jan 12, 2026
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
leetcodemediumstringbacktrackingrecursion
leetcodemediumstringbacktrackingrecursiondfs
Jan 12, 2026
The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other.
leetcodehardarraybacktrackingrecursion
leetcodehardarraybacktrackingrecursionconstraint-satisfaction
Jan 12, 2026
Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character.
leetcodeeasystringtwo-pointersstack
leetcodeeasystringtwo-pointersstacksimulation
Jan 11, 2026
Given a list of accounts where each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the elements are emails...
leetcodemediumarrayhash-tablestringunion-finddfs
leetcodemediumarrayhash-tablestringunion-finddisjoint-setdfs
Jan 10, 2026
Given a m x n grid filled with non-negative numbers, find a path from top-left to bottom-right, which minimizes the sum of all numbers along its path.
leetcodemediumarraydynamic-programmingmatrix
leetcodemediumarraydynamic-programmingmatrixgrid
Jan 10, 2026
Given an array of integers arr and an integer d. In one step you can jump from index i to index:
leetcodehardarraydynamic-programmingdfsmemoization
leetcodehardarraydynamic-programmingdfsmemoizationrecursion
Jan 9, 2026
Given an integer array nums, return the number of longest increasing subsequences.
leetcodemediumarraydynamic-programming
leetcodemediumarraydynamic-programminglongest-increasing-subsequence
Jan 8, 2026
Given an array of strings words and an integer k, return the k most frequent strings.
leetcodemediumhash-tableheapsortingstring
leetcodemediumhash-tableheapsortingstringpriority-queue
Jan 8, 2026
Given a string s, return the longest palindromic substring in s.
leetcodemediumstringtwo-pointersdynamic-programming
leetcodemediumstringtwo-pointerspalindromeexpand-around-centermanacher
Jan 7, 2026
Given an n-ary tree, return the level order traversal of its nodes’ values.
leetcodemediumtreebfsn-ary-tree
leetcodemediumtreebfslevel-order-traversaln-ary-tree
Jan 7, 2026
You have a graph of n nodes labeled from 0 to n - 1. You are given an integer n and an array edges where edges[i] = [ai, bi] indicates...
leetcodemediumgraphbfsdfsunion-find
leetcodemediumgraphbfsconnected-componentsundirected-graph
Jan 7, 2026
Given the root of a binary tree, return the level order traversal of its nodes’ values. (i.e., from left to right, level by level).
leetcodemediumtreebfsbinary-tree
leetcodemediumtreebfslevel-order-traversalbinary-tree
Jan 7, 2026
Given the root of a binary tree with unique values and the values of two different nodes of the tree x and y, return true if the nodes corresponding to...
leetcodeeasytreebfsbinary-tree
leetcodeeasytreebfsbinary-treelevel-order-traversal
Jan 6, 2026
Given the root of a binary tree, return the zigzag level order traversal of its nodes’ values. (i.e., from left to right, then right to left for the next level...
leetcodemediumtreebfsbinary-tree
leetcodemediumtreebfslevel-order-traversaldequebinary-tree
Jan 5, 2026
Given an integer array nums and an integer k, return the kth largest element in the array.
leetcodemediumarrayheapquickselectdivide-and-conquer
leetcodemediumarrayheappriority-queuequickselectdivide-and-conquersorting
Jan 5, 2026
Welcome to the Heap templates page! Here you’ll find battle-tested Python snippets for every common heap (priority queue) pattern on LeetCode — from basic min/max heaps to advanced techniques like...
leetcodetemplatesheappriority-queue
leetcodetemplatesheappriority-queuedata-structures
Jan 4, 2026
Given an integer array nums, find the subarray with the largest sum, and return its sum.
leetcodemediumarraydynamic-programminggreedydivide-and-conquer
Jan 4, 2026
A wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative....
leetcodemediumarraydynamic-programminggreedy
Jan 4, 2026
You are given two arrays rowSum and colSum of non-negative integers where rowSum[i] is the sum of the elements in the i-th row and colSum[j] is the sum of the...
leetcodemediumarraymatrixgreedy
Jan 4, 2026
Given a string s and an integer k, return true if you can use all the characters in s to construct k palindrome strings or false otherwise.
leetcodemediumstringgreedyhash-table
Jan 4, 2026
You are given two strings s1 and s2 of equal length consisting of only letters 'x' and 'y'.
leetcodemediumstringmathgreedy
Jan 4, 2026
A company is planning to interview 2n people. Given the array costs where costs[i] = [aCosti, bCosti], the cost of flying the i-th person to city a is aCosti, and...
leetcodemediumarraygreedysorting
Jan 4, 2026
There are n children standing in a line. Each child is assigned a rating value given in the integer array ratings.
leetcodehardarraygreedy
Jan 4, 2026
You are assigned to put some amount of boxes onto one truck. You are given a 2D array boxTypes, where boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi]:
leetcodeeasyarraygreedysorting
Jan 4, 2026
We have n chips, where the position of the i-th chip is position[i].
leetcodeeasyarraymathgreedy
Jan 3, 2026
Given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), ..., (an, bn) such that the sum of min(ai, bi) for all...
leetcodeeasyarraygreedysorting
Jan 3, 2026
You are given an integer array prices where prices[i] is the price of a given stock on the i-th day.
leetcodemediumarraygreedydynamic-programming
Jan 3, 2026
Given two strings s and t, return true if s is a subsequence of t, or false otherwise.
leetcodeeasystringtwo-pointersgreedydynamic-programming
Jan 3, 2026
You are given an integer array nums. You are initially positioned at the array’s first index, and each element in the array represents your maximum jump length at that position....
leetcodemediumarraygreedydynamic-programming
Jan 3, 2026
There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D array points where points[i] = [xstart, xend] denotes a...
leetcodemediumarraygreedysortingintervals
Jan 3, 2026
Given an array of intervals intervals where intervals[i] = [starti, endi], return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.
leetcodemediumarraygreedysortingintervalsdynamic-programming
Jan 3, 2026
At a lemonade stand, each lemonade costs 5. Customers are standing in a queue to buy from you and order one at a time (in the order specified by bills)....
leetcodeeasyarraygreedysimulation
Jan 3, 2026
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie.
leetcodeeasyarraygreedysortingtwo-pointers
Jan 2, 2026
Android devices have a special lock screen with a 3 x 3 grid of dots. Users can set an “unlock pattern” by connecting the dots in a specific sequence, which...
leetcodemediumbacktrackingrecursiondynamic-programming
Jan 1, 2026
You are given a string s and array queries where queries[i] = [left, right, k]. We may rearrange the substring s[left...right] and then choose up to k of its characters...
leetcodemediumstringbit-manipulationprefix-sumhash-table
Jan 1, 2026
Given an integer array nums, handle multiple queries of the following type:
leetcodeeasyarraydesignprefix-sum
Jan 1, 2026
Given an integer array data representing the data, return whether it is a valid UTF-8 encoding (i.e., it translates to a sequence of valid UTF-8 encoded characters).
leetcodemediumbit-manipulationstringarray
Jan 1, 2026
Given a 2D matrix matrix, handle multiple queries of the following types:
leetcodeharddesigndata-structuresprefix-summatrix
Jan 1, 2026
LeetCode wants to give one of its best employees the option to travel among n cities to collect algorithm problems. But all work and no play makes Jack a dull...
leetcodeharddynamic-programminggraphoptimization
Jan 1, 2026
Given a rows x cols screen and a sentence represented as a list of strings, return the number of times the given sentence can be fitted on the screen.
leetcodemediumdynamic-programmingstringsimulation
Jan 1, 2026
The next greater element of some element x in an array is the first greater element that is to the right of x in the same array.
leetcodeeasyarraystackmonotonic-stackhash-table
Jan 1, 2026
Given a sorted integer array nums and three integers a, b, and c, apply a quadratic function f(x) = ax² + bx + c to each element nums[i] in the...
leetcodemediumarraytwo-pointersmathparabola
Dec 31, 2025
A Range Module is a module that tracks ranges of numbers. Design a data structure to track the ranges represented as half-open intervals [left, right).
leetcodeharddesigndata-structuresintervalmaptree-map
Dec 31, 2025
A word square is a sequence of words where the k-th row and k-th column read the same string.
leetcodehardbacktrackingtrierecursionstring
Dec 31, 2025
Given the root of a binary search tree and a target value, return the value in the BST that is closest to the target. If there are multiple answers, print...
leetcodeeasybinary-search-treetreerecursionbinary-search
Dec 31, 2025
In this problem, a rooted tree is a directed graph such that there is exactly one node (the root) for which all other nodes are descendants of this node, plus...
leetcodehardunion-finddsugraphcycle-detectiondirected-graph
Dec 31, 2025
Given the root of a binary search tree (BST) and a node p in it, return the in-order successor of that node in the BST. If the given node has...
leetcodemediumbinary-search-treetreeinorder-traversal
Dec 31, 2025
Given a binary array nums, return the maximum number of consecutive 1’s in the array if you can flip at most one 0.
leetcodemediumarraydynamic-programmingsliding-window
Dec 31, 2025
An image smoother is a filter of the size 3 x 3 that can be applied to each cell of an image by rounding down the average of the cell...
leetcodeeasymatrixarraysimulation
Dec 31, 2025
You are given a string s and an array of strings words. You should add a closed pair of bold tag <b> and </b> to wrap the substrings in s...
leetcodemediumstringarraygreedy
Dec 30, 2025
Given a time represented in the format "HH:MM", form the next closest time by reusing the current digits. There is no limit on how many times a digit can be...
leetcodemediumstringsimulationbrute-force
Dec 30, 2025
You have n bulbs in a row numbered from 1 to n. Initially, all the bulbs are turned off. On day i (for i from 0 to n-1), we turn...
leetcodemediumsliding-windowtwo-pointersarray
Dec 30, 2025
Given two strings a and b, return the minimum number of times you should repeat string a so that string b is a substring of it. If it is impossible...
leetcodemediumstring-matchingkmprabin-karprolling-hash
Dec 29, 2025
In this problem, a tree is an undirected graph that is connected and has no cycles.
leetcodemediumunion-finddsugraphcycle-detectiondfs
Dec 28, 2025
You are in a city that consists of n intersections numbered from 0 to n - 1 with bi-directional roads between some intersections. The inputs are generated such that you...
leetcodemediumdijkstrashortest-pathgraphdynamic-programming
Dec 18, 2025
There are n cities. Some of them are connected, while some are not. If city a is connected directly with city b, and city b is connected directly with city...
leetcodealgorithmmediumcppdisjoint-setdfsgraphproblem-solving
Dec 17, 2025
You are given an array of variable pairs equations and an array of real numbers values, where equations[i] = [Ai, Bi] and values[i] represent the equation Ai / Bi =...
leetcodealgorithmmediumcppdisjoint-setgraphdfsproblem-solving
Dec 16, 2025
You have a data structure of employee information, including the employee’s unique ID, importance value, and direct subordinates’ IDs.
leetcodealgorithmmediumcppdfsbfshash-tableproblem-solving
Dec 16, 2025
You are given a 2D array of axis-aligned rectangles. For each rectangle[i] = [xi1, yi1, xi2, yi2], where (xi1, yi1) is the bottom-left corner and (xi2, yi2) is the top-right...
leetcodealgorithmhardcppgeometrysweep-linesegment-treeproblem-solving
Dec 14, 2025
You are given an m x n grid rooms initialized with these three possible values:
leetcodealgorithmmediumcpparraymatrixbfsproblem-solving
Dec 14, 2025
Given an integer n, return the least number of perfect square numbers that sum to n.
leetcodealgorithmmediumcppmathdynamic-programmingbfsproblem-solving
Dec 14, 2025
Greedy algorithms are among the most elegant tools in competitive programming — when they work, they’re simpler and faster than dynamic programming. This guide covers the core greedy patterns you’ll...
leetcodetemplatesgreedy
leetcodetemplatesgreedyalgorithms
Dec 14, 2025
Given a stream of integers and a window size, calculate the moving average of all integers in the sliding window.
leetcodealgorithmeasycppqueuesliding-windowdesignproblem-solving
Dec 13, 2025
You are given an m x n grid where each cell can have one of three values:
leetcodealgorithmmediumcpparraymatrixbfsproblem-solving
Dec 11, 2025
Given an array of meeting time intervals intervals where intervals[i] = [starti, endi], return the minimum number of conference rooms required.
leetcodealgorithmmediumcpparraysortingpriority-queuetwo-pointersproblem-solving
Dec 11, 2025
Given two binary strings a and b, return their sum as a binary string.
leetcodealgorithmeasycppstringmathbit-manipulationproblem-solving
Dec 10, 2025
Given two 1d vectors, implement an iterator to return their elements alternately.
leetcodealgorithmmediumcppdesigniteratorproblem-solving
Dec 3, 2025
Design a Skiplist without using any built-in libraries.
leetcodealgorithmhardcppdata-structuresskiplistlinked-listproblem-solving
Dec 2, 2025
Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order...
leetcodealgorithmmediumcpparraytwo-pointerssortingproblem-solving
Dec 2, 2025
Given the coordinates of four points in 2D space p1, p2, p3, and p4, return true if the four points construct a square.
leetcodealgorithmmediumcppmathgeometryproblem-solving
Dec 2, 2025
Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.
leetcodealgorithmmediumcppdesigndata-structureshash-maplinked-listproblem-solving
Dec 2, 2025
Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.
leetcodealgorithmmediumcppdesigndata-structureshash-maplinked-listproblem-solving
Nov 24, 2025
[Medium] Round Trip Ticket Cost Minimization
algorithmmediumcpparrayoptimizationproblem-solving
algorithmmediumarrayoptimizationgreedytwo-pointers
Nov 24, 2025
You have planned some train traveling one year in advance. The days of the year in which you will travel are given as an integer array days. Each day is...
leetcodealgorithmmediumcppdynamic-programmingproblem-solving
leetcodemediumdynamic-programmingdpoptimization
Nov 24, 2025
Given a string s, return the number of palindromic substrings in it.
leetcodealgorithmmediumcppstringtwo-pointersproblem-solving
leetcodemediumstringtwo-pointerspalindromeexpand-around-center
Nov 24, 2025
Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input....
leetcodealgorithmmediumcpparraysortingintervalproblem-solving
leetcodemediumarraysortingintervalsmerge
Nov 24, 2025
You are given a 0-indexed array of positive integers w where w[i] describes the weight of the ith index.
leetcodealgorithmmediumcppdesignbinary-searchprefix-sumproblem-solving
leetcodemediumdesignbinary-searchprefix-sumweighted-random
Nov 24, 2025
Given an integer array nums with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array....
leetcodealgorithmmediumcpphash-tablereservoir-samplingproblem-solving
leetcodemediumhash-tablereservoir-samplingdesignrandomization
Nov 24, 2025
Suppose you are at a party with n people (labeled from 0 to n - 1) and among them, there may exist one celebrity. The definition of a celebrity is...
leetcodealgorithmmediumcppgraphtwo-pointersproblem-solving
leetcodemediumgraphtwo-pointerscelebrity
Nov 24, 2025
There are n buildings in a line. You are given an integer array heights of size n that represents the heights of the buildings in the line.
leetcodealgorithmmediumcpparraystackmonotonic-stackproblem-solving
leetcodemediumarraystackmonotonic-stackgreedytwo-pointers
Nov 24, 2025
You are given the root of a binary tree containing digits from 0 to 9 only.
leetcodealgorithmmediumcpptreedfsproblem-solving
leetcodemediumtreedfsrecursionbinary-tree
Nov 24, 2025
You are given a string s and an integer k, a k duplicate removal consists of choosing k adjacent and equal letters from s and removing them, causing the left...
leetcodealgorithmmediumcppstringstacktwo-pointersproblem-solving
leetcodemediumstringstacktwo-pointersin-place
Nov 24, 2025
Given a robot cleaner in a room modeled as a grid.
leetcodealgorithmhardcppdfsbacktrackingproblem-solving
leetcodeharddfsbacktrackingrobotsimulation
Nov 24, 2025
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.
leetcodealgorithmhardcppstringdynamic-programmingstackproblem-solving
leetcodehardstringdynamic-programmingstacktwo-pointersgreedy
Nov 24, 2025
Given the root node of a binary search tree and two integers low and high, return the sum of values of all nodes with a value in the inclusive range...
leetcodealgorithmeasycpptreebstdfsproblem-solving
leetcodeeasytreebstdfsrecursion
Nov 24, 2025
A string can be abbreviated by replacing any number of non-adjacent, non-empty substrings with their lengths. The lengths should not have leading zeros.
leetcodealgorithmeasycppstringtwo-pointersproblem-solving
leetcodeeasystringtwo-pointersparsing
Nov 24, 2025
You are given a string s consisting of lowercase English letters. A duplicate removal consists of choosing two adjacent and equal letters and removing them.
leetcodealgorithmeasycppstringstacktwo-pointersproblem-solving
leetcodeeasystringstacktwo-pointersin-place
Nov 24, 2025
Welcome to the String Processing template collection! These are ready-to-use C++ snippets for the core string patterns: sliding window, two pointers, string matching, manipulation, and parsing. If you already know...
leetcodetemplatesstring
leetcodetemplatesstringalgorithms
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
leetcodetemplatesqueuedata-structures
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
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
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
leetcodetemplatesdfsgraphtraversal
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
leetcodetemplatesdesigndata-structures
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
leetcodetemplatesbfsgraphtraversal
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
leetcodetemplatesbacktrackingdfs
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
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
leetcodemediumdfsgraphmatrixconnected-components
Nov 18, 2025
Given an array of integers arr, sort the array by performing a series of pancake flips.
leetcodealgorithmmediumcpparraysortingproblem-solving
leetcodemediumarraysortinggreedypancake-flip
Nov 18, 2025
Given an array of strings strs, group the anagrams together. You can return the answer in any order.
leetcodealgorithmmediumcppstringhash-tableproblem-solving
leetcodemediumstringhash-tableanagramcounting
Nov 18, 2025
You are given a 0-indexed array of integers nums of length n. You are initially positioned at nums[0].
leetcodealgorithmmediumcpparraygreedyproblem-solving
leetcodemediumarraygreedybfsoptimization
Nov 18, 2025
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two...
leetcodealgorithmmediumcpplinked-listrecursionproblem-solving
leetcodemediumlinked-listrecursionmathcarry
Nov 18, 2025
You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. The only constraint stopping you from robbing each of...
leetcodealgorithmmediumcppdynamic-programmingdpproblem-solving
leetcodemediumdynamic-programmingdparrayoptimization
Nov 18, 2025
The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1....
leetcodealgorithmeasycppdynamic-programmingrecursionproblem-solving
leetcodeeasydynamic-programmingrecursionmathfibonacci
Nov 18, 2025
Given the head of a linked list and an integer val, remove all the nodes of the linked list that has Node.val == val, and return the new head.
leetcodealgorithmeasycpplinked-listiterationproblem-solving
leetcodeeasylinked-listtwo-pointersdummy-node
Nov 17, 2025
Given a 2D integer array nums, return all elements of nums in diagonal order.
leetcodealgorithmmediumcpparraymatrixhash-mapbfsproblem-solving
Nov 16, 2025
Given the head of a singly linked list, reverse the list, and return the reversed list.
leetcodealgorithmeasycpplinked-listrecursioniterationproblem-solving
Nov 15, 2025
Design a data structure that follows the constraints of a Least Recently Used (LRU) cache.
leetcodealgorithmmediumcppdesigndata-structureshash-maplinked-listproblem-solving
Nov 14, 2025
A valid IP address consists of exactly four integers separated by single dots. Each integer is between 0 and 255 (inclusive) and cannot have leading zeros.
leetcodealgorithmmediumcppbacktrackingstringproblem-solving
Nov 14, 2025
Design and implement a data structure for a Least Frequently Used (LFU) cache.
leetcodealgorithmhardcppdesigndata-structureshash-maplinked-listproblem-solving
Nov 14, 2025
The stack is one of the most versatile data structures in coding interviews. Whether you’re matching parentheses, evaluating expressions, or finding the next greater element in an array, a stack...
leetcodetemplatesstackdata-structures
leetcodetemplatesstackdata-structures
Nov 14, 2025
Minimal, copy-paste Python for expression evaluation with +, −, ×, ÷ and parentheses. See also Stack for RPN and nested expressions.
leetcodetemplatescalculatorexpression-evaluation
leetcodetemplatescalculatorexpression-evaluationstack
Nov 14, 2025
Given a string s representing a valid expression, implement a basic calculator to evaluate it, and return the result of the evaluation.
leetcodealgorithmmediumcppstringstackexpression-evaluationproblem-solving
leetcodemediumstringstackcalculatorexpression-evaluationparentheses
Nov 14, 2025
Implement a basic calculator to evaluate a simple expression string.
leetcodealgorithmhardcppstringstackrecursionexpression-evaluationproblem-solving
leetcodehardstringstackcalculatorrecursionexpression-evaluationparentheses
Nov 14, 2025
Given a string s which represents an expression, evaluate this expression and return its value.
leetcodealgorithmmediumcppstringstackexpression-evaluationproblem-solving
leetcodemediumstringstackcalculatorexpression-evaluation
Nov 5, 2025
Rearrange nums such that nums[0] < nums[1] > nums[2] < nums[3] ... (wiggle order).
leetcodealgorithmmediumcpparraysnth-elementthree-way-partitionindex-mappingproblem-solving
leetcodemediumarraywigglenth_elementpartition
Nov 5, 2025
A parentheses string is valid if and only if:
leetcodealgorithmmediumcppstringstackgreedyproblem-solving
leetcodemediumstringstackparenthesesgreedycounting
Nov 5, 2025
Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.
leetcodealgorithmeasycppstringstackproblem-solving
leetcodeeasystringstackparenthesesvalidation
Nov 5, 2025
Given a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1.
leetcodealgorithmmediumcpparrayshash-mapprefix-sumproblem-solving
leetcodemediumarrayhash-mapprefix-sumsubarray
Nov 5, 2025
The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean...
leetcodealgorithmhardcpparraysmultisetsliding-windowtwo-heapsproblem-solving
leetcodehardarraymultisetsliding-windowtwo-heapsmedian
Nov 5, 2025
You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right....
leetcodealgorithmhardcpparraysdequesliding-windowmonotonic-queueproblem-solving
leetcodehardarraydequesliding-windowmonotonic-queue
Nov 5, 2025
Given a binary array nums, return the maximum number of consecutive 1’s in the array.
leetcodealgorithmeasycpparrayssliding-windowproblem-solving
leetcodeeasyarraysliding-windowcounting
Nov 5, 2025
Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that:
leetcodealgorithmmediumcpparraystwo-pointerssortingproblem-solving
Oct 29, 2025
Trees are one of the most frequently tested data structures in coding interviews. This page collects ready-to-use C++ templates for every major tree pattern — from basic traversals to advanced...
leetcodetemplatestrees
leetcodetemplatestrees
Oct 29, 2025
Minimal, copy-paste Python for combinatorics (nCk mod P) and 2D geometry primitives (cross product, point on segment).
leetcodetemplatesmathgeometry
leetcodetemplatesmathgeometry
Oct 29, 2025
Graph algorithms are among the most versatile tools in competitive programming and coding interviews. A graph is simply a collection of nodes (vertices) connected by edges, and nearly every “network,”...
leetcodetemplatesgraph
leetcodetemplatesgraph
Oct 29, 2025
Dynamic Programming is the most common pattern in LeetCode Medium/Hard problems. If you only learn one advanced technique, make it DP.
leetcodetemplatesdynamic-programming
leetcodetemplatesdp
Oct 29, 2025
This page is your toolbox of essential data structures for LeetCode. Each template is self-contained C++ you can copy directly into your solution. They range from beginner-friendly (binary search, prefix...
leetcodetemplatesdata-structuresalgorithms
leetcodetemplatesdata-structuresalgorithms
Oct 29, 2025
Arrays and strings are the foundation of coding interviews — you’ll encounter them in nearly every problem set. This page provides battle-tested Python templates for the most important patterns: sliding...
leetcodetemplatesarraysstrings
leetcodetemplatesarraysstrings
Oct 29, 2025
This page covers specialized algorithmic techniques that appear in Hard-level LeetCode problems and competitive programming. These are not everyday patterns — most interviews won’t require them — but when a...
leetcodetemplatesadvanced
leetcodetemplatesadvanced
Oct 29, 2025
LeetCode Categories and Solution Templates
leetcodealgorithmproblem-solvingtemplates
leetcodetemplatespatternsdpgraphsliding-windowtwo-pointersbinary-search
Oct 29, 2025
Given a binary array bits that ends with 0, determine whether the last character must be a 1-bit character.
leetcodeeasyarrayparsing
leetcodeeasyarrayparsing
Oct 29, 2025
Reverse the array of characters s in-place using O(1) extra memory.
leetcodeeasytwo-pointersstring
leetcodeeasytwo-pointersstring
Oct 28, 2025
Difficulty: Medium
Category: Linked List, Circular List
Companies: Amazon, Facebook, Google, Microsoft
leetcodemediumlinked-listcircular
leetcodemediumlinked-listcircularinsertiontwo-pointers
Oct 28, 2025
Difficulty: Medium
Category: Stack, Parsing, Simulation
Companies: Amazon, Facebook, Google, Twitter
leetcodemediumstackparsing
leetcodemediumstackparsinglogssimulation
Oct 25, 2025
Difficulty: Medium
Category: Tree, DFS, BFS
Companies: Amazon, Facebook, Google, Microsoft, Apple
leetcodemediumtreedfsbfs
leetcodemediumtreebinary-treedfsbfsgraphrecursion
Oct 22, 2025
Difficulty: Medium
Category: String, Stack
Companies: Amazon, Facebook, Microsoft, Google
leetcodemediumstringstack
leetcodemediumstringstackparenthesesvalidation
Oct 22, 2025
Difficulty: Medium
Category: Array, Sorting, Simulation
Companies: Amazon, Google, Microsoft, Uber
leetcodemediumarraysorting
leetcodemediumarraysortingsimulationbucket-sort
Oct 22, 2025
Difficulty: Medium
Category: Tree, Linked List, DFS
Companies: Amazon, Microsoft, Facebook
leetcodemediumtreelinked-list
leetcodemediumtreelinked-listbstinorder-traversalrecursion
Oct 22, 2025
Difficulty: Medium
Category: Design, Array, Matrix
Companies: Amazon, Google, Microsoft, Facebook
leetcodemediumdesignarray
leetcodemediumdesignarraymatrixoptimization
Oct 22, 2025
Difficulty: Medium
Category: Array, Matrix, DFS
Companies: Amazon, Google, Microsoft
leetcodemediumarraymatrix
leetcodemediumarraymatrixdfsbattleship
Oct 21, 2025
Difficulty: Medium
Category: Tree, DFS, Binary Tree
Companies: Amazon, Google, Facebook, Microsoft
leetcodemediumtreedfs
leetcodemediumtreedfsbinary-treeboundary-traversal
Oct 21, 2025
Difficulty: Medium
Category: Array, Hash Table, Heap, Bucket Sort, Quickselect
Companies: Amazon, Google, Facebook, Microsoft, Apple
leetcodemediumarrayhash-tableheap
leetcodemediumarrayhash-tableheapbucket-sortquickselect
Oct 21, 2025
Difficulty: Medium
Category: Array, Sorting, Heap, Quickselect
Companies: Amazon, Google, Facebook, Microsoft
leetcodemediumarraysorting
leetcodemediumarraysortingheapquickselect
Oct 21, 2025
Difficulty: Easy
Category: Array, Hash Table
Companies: Amazon, Google, Microsoft
leetcodeeasyarrayhash-table
leetcodeeasyarrayhash-tablecounting
Oct 20, 2025
There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates...
leetcodemediumgraphtopological-sortcycle-detection
Oct 20, 2025
Given a reference of a node in a connected undirected graph.
leetcodemediumgraphdfsbfsclone
Oct 20, 2025
You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'. The wheels can...
leetcodemediumbfsshortest-pathlock
Oct 20, 2025
Given the root of a binary tree, return the vertical order traversal of its nodes’ values. (i.e., from top to bottom, column by column).
leetcodemediumtreebfsvertical-order
Oct 20, 2025
You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.
leetcodemediumdynamic-programmingdpcoin-change
Oct 20, 2025
Difficulty: Medium
Category: Backtracking, Recursion, Duplicates
leetcodealgorithmmediumbacktrackingrecursionduplicates
Oct 20, 2025
Given two integers n and k, return all possible combinations of k numbers chosen from the range [1, n].
leetcodemediumbacktrackingrecursioncombinations
Oct 20, 2025
Difficulty: Medium
Category: Backtracking, Recursion
leetcodealgorithmmediumbacktrackingrecursion
Oct 20, 2025
Difficulty: Medium
Category: Tree, Binary Tree, LCA
leetcodealgorithmmediumtreebinary-treelca
Oct 20, 2025
Difficulty: Medium
Category: Design, Data Structure
leetcodealgorithmmediumdesigndata-structure
Oct 20, 2025
Difficulty: Medium
Category: Tree, DFS, BFS, Graph
leetcodealgorithmmediumtreedfsbfsgraph
Oct 20, 2025
Difficulty: Hard
Category: Stack, Monotonic Stack
leetcodealgorithmhardstackmonotonic-stack
Oct 20, 2025
Difficulty: Medium
Category: DFS, Graph, Matrix
leetcodealgorithmmediumdfsgraphmatrix
Oct 20, 2025
Difficulty: Medium
Category: Run-Length Encoding, Two Pointers, Array Processing
leetcodealgorithmmediumrun-length-encodingtwo-pointersarray-processing
Oct 20, 2025
Given two sparse vectors, compute their dot product.
leetcodealgorithmmediumcpphash-mapdata-structureoptimizationproblem-solving
Oct 20, 2025
You are given two integer arrays nums1 and nums2. You are tasked to implement a data structure that supports the following operations:
leetcodealgorithmmediumcpphash-mapdata-structureproblem-solving
Oct 20, 2025
Given the root of a binary tree and an integer targetSum, return the number of paths where the sum of the values along the path equals targetSum.
leetcodealgorithmmediumcpptreedfsrecursionproblem-solving
Oct 20, 2025
Given an encoded string, return its decoded string.
leetcodealgorithmmediumcppstackstring-processingproblem-solving
Oct 19, 2025
There is an m x n rectangular island that borders both the Pacific Ocean and the Atlantic Ocean. The Pacific Ocean touches the island’s left and top edges, and the...
leetcodealgorithmmediumcppdfsbfsgraphproblem-solving
Oct 19, 2025
You are given an array of people, people, which are the attributes of some people in a queue (not necessarily in order). Each people[i] = [hi, ki] represents the ith...
leetcodealgorithmmediumcppgreedysortinglistproblem-solving
Oct 18, 2025
The minimum product of a subarray is the minimum value in the subarray multiplied by the sum of the subarray.
leetcodealgorithmmediumcppstackmonotonic-stackprefix-sumproblem-solving
Oct 18, 2025
Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all...
leetcodealgorithmmediumcppstackmonotonic-stackgreedyproblem-solving
Oct 17, 2025
In English, we have a concept called root, which can be followed by some other word to form another longer word. Let’s call this word successor. For example, when the...
leetcodealgorithmmediumcpptriehash-setstring-processingproblem-solving
Oct 17, 2025
Given an integer array nums, return the length of the longest strictly increasing subsequence.
leetcodealgorithmmediumcppdynamic-programmingdpbinary-searchproblem-solving
Oct 17, 2025
Given a circular integer array nums (i.e., the next element of nums[nums.length - 1] is nums[0]), return the next greater number for every element in nums.
leetcodealgorithmmediumcppmonotonic-stackstackproblem-solving
Oct 17, 2025
You are given an integer array nums.
leetcodealgorithmmediumcppsliding-windowhash-mapproblem-solving
Oct 17, 2025
Given the integers zero, one, low, and high, we can construct a string by starting with an empty string, and then at each step perform either of the following:
leetcodealgorithmmediumcppdynamic-programmingdpproblem-solving
Oct 16, 2025
We are given hours, a list of the number of hours worked per day for a given employee.
leetcodealgorithmmediumcpphash-mapprefix-sumproblem-solving
Oct 15, 2025
You are given an integer array nums and an integer target.
leetcodealgorithmmediumcppdynamic-programmingdpsubset-sumproblem-solving
Oct 10, 2025
Given a string s, find the length of the longest substring without repeating characters.
leetcodealgorithmmediumcppsliding-windowhash-mapstringtwo-pointersproblem-solving
Oct 8, 2025
Write an efficient algorithm that searches for a value target in an m x n integer matrix. This matrix has the following properties:
leetcodealgorithmmediumcppbinary-searchmatrix2d-arraydivide-conquersearchoptimizationproblem-solving
Oct 6, 2025
Given an array of integers nums, sort the array in ascending order and return it.
leetcodealgorithmmediumcppsortingmerge-sortheap-sortcounting-sortdata-structuresdivide-conquerproblem-solving
Oct 5, 2025
A city’s skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Given the locations and heights of all...
leetcodealgorithmhardcppsweep-linepriority-queuedata-structuresunion-findproblem-solving
Oct 4, 2025
You are given an array of strings equations that represent relationships between variables. Each string equations[i] is of length 4 and takes one of two different forms: "xi==yi" or "xi!=yi"....
leetcodealgorithmdata-structuresdisjoint-setgraphdfsmediumcppconnected-componentsgraph-coloringproblem-solving
Oct 3, 2025
Given an integer n, return the number of structurally unique BST’s (binary search trees) that have exactly n nodes with values from 1 to n.
leetcodealgorithmdynamic-programmingdata-structuresmathcatalan-numbersmediumcppbinary-search-treesproblem-solving
Sep 30, 2025
Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s.
leetcodealgorithmbacktrackingdata-structuresstringpalindromerecursionmediumcpppartitioningproblem-solving
Sep 29, 2025
This is a classic backtracking problem that requires generating all possible combinations of k numbers chosen from the range [1, n]. The key insight is using DFS with backtracking to...
leetcodealgorithmbacktrackingdata-structuresrecursionmediumcppcombinationsdfsproblem-solving
Sep 25, 2025
An n-bit gray code sequence is a sequence of 2^n integers where:
leetcodealgorithmbacktrackingdata-structuresrecursionbit-manipulationmediumcppgray-codeproblem-solving
Sep 25, 2025
Given an m x n matrix, return all elements of the matrix in spiral order.
leetcodealgorithmmatrixdata-structuressimulationtraversalmediumcppspiral-matrixproblem-solving
Sep 25, 2025
Implement pow(x, n), which calculates x raised to the power n (i.e., x^n).
leetcodealgorithmmathdata-structuresrecursionbit-manipulationmediumcpppowproblem-solving
Sep 24, 2025
This is a classic dynamic programming problem that requires finding the number of unique paths from top-left to bottom-right of a grid. The key insight is recognizing the overlapping subproblems...
leetcodealgorithmdynamic-programmingdata-structuresgridcombinatoricsmediumcppunique-pathsproblem-solving
Sep 24, 2025
This is a complex linked list problem that requires reversing nodes in groups of k. The key insight is using recursion to handle the grouping and a helper function to...
leetcodealgorithmlinked-listrecursivedata-structurespointershardcppreverse-nodesk-grouprecursionproblem-solving
Sep 24, 2025
This is a matrix manipulation problem that requires rotating a 2D matrix 90 degrees clockwise in-place. The key insight is understanding the relationship between matrix positions during rotation and implementing...
leetcodealgorithmmatrixdata-structures2d-arraytransformationmediumcpprotate-imagein-placeproblem-solving
Sep 24, 2025
This is a classic stack problem that requires evaluating mathematical expressions written in Reverse Polish Notation (RPN). The key insight is using a stack to process operands and operators in...
leetcodealgorithmstackdata-structuresmathematical-expressionmediumcppreverse-polish-notationrpnproblem-solving
Sep 24, 2025
leetcodealgorithmbfsgraphdata-structuresmatrixshortest-pathhardcppshortest-distancebuildingsproblem-solving
Sep 24, 2025
This is a multithreading problem that requires implementing a concurrent web crawler. The key insight is using proper synchronization mechanisms to avoid race conditions while crawling URLs from the same...
leetcodealgorithmmultithreadingconcurrencydata-structuressynchronizationmediumcppweb-crawlerconcurrent-programmingproblem-solving
Sep 24, 2025
This is a simulation problem that requires understanding the rules of Tic-Tac-Toe and validating whether a given board state is possible. The key insight is checking the count of X’s...
leetcodealgorithmsimulationdata-structuresgame-logicvalidationmediumcpptic-tac-toegame-validationproblem-solving
Sep 24, 2025
Meta‑Style LeetCode Question List
leetcodealgorithmmetainterview-preparationpractice-listfaangcoding-interviewproblem-solvingcompetitive-programmingdata-structures
Sep 24, 2025
🧩 Hash Table Mastery List
leetcodealgorithmhashdata-structuresinterview-preparationpractice-listhash-tablehash-mapproblem-solvingcompetitive-programming
Sep 24, 2025
LeetCode Linked List Mastery List
leetcodealgorithmlinked-listdata-structuresinterview-preparationpractice-listproblem-solvingcompetitive-programmingpointerstraversal
Sep 24, 2025
This is a classic linked list problem that requires understanding how to manipulate pointers and traverse linked lists. The key insight is understanding pointer manipulation, recursion, and iterative approaches with...
leetcodealgorithmlinked-listrecursivedata-structurespointersmediumcppswap-nodesrecursioniterativeproblem-solving
Sep 23, 2025
📚 Python Quick Reference for LeetCode
pythondata-structuresreferencecheat-sheetprogrammingcontainersalgorithmscompetitive-programmingguide
pythonreferencecheat-sheetleetcodeguide
Sep 23, 2025
There is an integer array nums sorted in ascending order (with distinct values), rotated at an unknown pivot. Given nums and target, return the index of target or -1 if...
leetcodemediumbinary-searcharray
leetcodemediumbinary-searcharraysearch