Get ready for interviews
Practice problems
160 problems of the kind asked in interviews, in Arabic and English. Write your solution in JavaScript, Python or C++; it's judged against hidden tests, with hints and a worked solution for every problem.
Try a full mock interviewProblem of the dayPaths through a gridSolve it →
Sign in to track your progress
0 / 160
- 0/48
- 0/97
- 0/15
Problems
- Pair with target sumarray · hash mapEasy
- Contains a duplicatearray · hash setEasy
- Is it an anagram?string · hash map · countingEasy
- Group the anagramsstring · hash map · sortingMedium
- Top k most frequentarray · hash map · sorting · bucket sortMedium
- Product of everything elsearray · prefix sumsMedium
- Longest consecutive runarray · hash setMedium
- The missing numberarray · math · bit manipulationEasy
- Zeros to the endarray · two pointersEasy
- FizzBuzzmath · stringEasy
- Reverse the wordsstring · two pointersMedium
- Palindrome after cleaningstring · two pointersEasy
- Pair in a sorted listarray · two pointers · binary searchEasy
- Three numbers summing to zeroarray · two pointers · sortingMedium
- Largest water containerarray · two pointers · greedyMedium
- Longest substring without repeatsstring · sliding window · hash mapMedium
- Best time to buy and sellarray · greedy · sliding windowEasy
- Longest common prefixstringEasy
- Roman numeralsstring · hash map · mathEasy
- Balanced bracketsstack · stringEasy
- Days until a warmer daystack · monotonic stack · arrayMedium
- Binary searchbinary search · arrayEasy
- Search a rotated listbinary search · arrayMedium
- Postfix calculatorstack · mathMedium
- Climbing stairsdynamic programming · mathEasy
- Maximum subarray sumarray · dynamic programming · greedyMedium
- Robbing a streetdynamic programming · arrayMedium
- Fewest coinsdynamic programming · bfsMedium
- Longest increasing subsequencedynamic programming · binary searchMedium
- Jump gamegreedy · arrayMedium
- Merge intervalsarray · sorting · intervalsMedium
- Count the islandsgraph · dfs · bfs · matrixMedium
- Rotate a matrix 90°matrix · array · mathMedium
- Spiral ordermatrix · simulationMedium
- Can you finish every course?graph · topological sort · bfsMedium
- Kth largest elementheap · sorting · quickselectMedium
- Word breakdynamic programming · string · hash setMedium
- Trapped rainwaterarray · two pointers · dynamic programming · stackHard
- Edit distancedynamic programming · stringHard
- The single numberarray · bit manipulationEasy
- Majority elementarray · counting · boyer-mooreEasy
- Plus onearray · mathEasy
- First unique characterstring · hash map · countingEasy
- Integer square rootbinary search · mathEasy
- Merge two sorted listsarray · two pointers · sortingEasy
- Subarrays summing to karray · hash map · prefix sumsMedium
- Paths through a griddynamic programming · math · combinatoricsMedium
- Ways to decodedynamic programming · stringMedium
- All subsetsbacktracking · recursion · bit manipulationMedium
- All permutationsbacktracking · recursionMedium
- Sliding window maximumsliding window · deque · monotonic queueHard
- Minimum window substringsliding window · hash map · stringHard
- Reverse a linked listlinked list · two pointers · recursionEasy
- Merge two sorted listslinked list · two pointers · recursionEasy
- Middle of a linked listlinked list · two pointers · fast and slow pointersEasy
- Remove duplicates from a sorted listlinked listEasy
- Palindrome linked listlinked list · two pointers · fast and slow pointersEasy
- Remove the nth node from the endlinked list · two pointersMedium
- Add two numbers stored in listslinked list · mathMedium
- Reorder a list front and backlinked list · two pointers · fast and slow pointersMedium
- Odd nodes before even nodeslinked listMedium
- Rotate a list rightlinked list · two pointersMedium
- Sort a linked listlinked list · sorting · merge sort · divide and conquerMedium
- Partition a list around a valuelinked list · two pointersMedium
- Swap nodes in pairslinked list · recursionMedium
- Reverse nodes in groups of klinked list · recursionHard
- Maximum depth of a binary treetree · dfs · bfs · recursionEasy
- Invert a binary treetree · dfs · bfs · recursionEasy
- Same treetree · dfs · recursionEasy
- Symmetric treetree · dfs · bfs · recursionEasy
- Diameter of a binary treetree · dfs · recursionEasy
- Balanced binary treetree · dfs · recursionEasy
- Root-to-leaf path sumtree · dfs · recursionEasy
- Subtree of another treetree · dfs · recursionEasy
- Sorted array to a balanced BSTtree · binary search tree · divide and conquerEasy
- Level order traversaltree · bfs · queueMedium
- Zigzag level ordertree · bfs · queueMedium
- Right side viewtree · bfs · dfsMedium
- Validate a binary search treetree · binary search tree · dfsMedium
- Kth smallest in a BSTtree · binary search tree · dfs · stackMedium
- Lowest common ancestor in a BSTtree · binary search treeMedium
- Count good nodestree · dfsMedium
- Build a tree from preorder and inordertree · divide and conquer · hash map · recursionMedium
- Maximum path sum in a treetree · dfs · dynamic programming · recursionHard
- Shortest path in a mazegraph · bfs · matrixMedium
- Network delay timegraph · dijkstra · heap · shortest pathMedium
- Number of connected componentsgraph · union find · dfsMedium
- Redundant connectiongraph · union findMedium
- Rotting orangesgraph · bfs · matrixMedium
- Course ordergraph · topological sort · heapMedium
- Is the graph bipartite?graph · bfs · dfs · graph coloringMedium
- Cheapest flight within k stopsgraph · shortest path · bellman-ford · dynamic programmingMedium
- Last stone weightheap · simulationEasy
- K closest points to the originheap · sorting · geometryMedium
- Task scheduler with cooldowngreedy · counting · heapMedium
- Word laddergraph · bfs · string · hash setHard
- Minimum cost to connect all pointsgraph · minimum spanning tree · primMedium
- Water flowing to both oceansgraph · dfs · bfs · matrixMedium
- Median of two sorted arraysbinary search · array · divide and conquerHard
- Min cost climbing stairsdynamic programming · arrayEasy
- Pascal's triangledynamic programming · array · mathEasy
- Longest common subsequencedynamic programming · stringMedium
- 0/1 knapsackdynamic programming · arrayMedium
- Partition into equal sumsdynamic programming · arrayMedium
- Ways to make changedynamic programming · arrayMedium
- Longest palindromic substringstring · two pointers · dynamic programmingMedium
- Count palindromic substringsstring · two pointers · dynamic programmingMedium
- Minimum path sumdynamic programming · matrixMedium
- Grid paths with obstaclesdynamic programming · matrixMedium
- House robber on a circledynamic programming · arrayMedium
- Maximum product subarraydynamic programming · arrayMedium
- Interleaving stringsdynamic programming · stringMedium
- Target sum with signsdynamic programming · backtracking · arrayMedium
- Distinct subsequencesdynamic programming · stringHard
- Longest increasing path in a matrixdynamic programming · dfs · memoization · matrixHard
- Combination sumbacktracking · recursion · arrayMedium
- Generate parenthesesbacktracking · recursion · stringMedium
- Phone number lettersbacktracking · string · hash mapMedium
- Word searchbacktracking · dfs · matrixMedium
- Palindrome partitioningbacktracking · string · dynamic programmingMedium
- N-queens countbacktracking · recursionHard
- Valid sudokuhash set · matrixMedium
- Longest repeat after k replacementsstring · sliding window · hash mapMedium
- Permutation in a stringstring · sliding window · hash mapMedium
- Shortest subarray reaching a sumarray · sliding window · prefix sumsMedium
- Sort three coloursarray · two pointers · sortingMedium
- Next permutationarray · two pointers · mathMedium
- Insert an intervalarray · intervalsMedium
- Fewest intervals to removegreedy · intervals · sortingMedium
- Meeting rooms neededintervals · sorting · heap · greedyMedium
- Search a sorted matrixbinary search · matrixMedium
- Minimum in a rotated sorted arraybinary search · arrayMedium
- Slowest eating speed that worksbinary search · arrayMedium
- Run-length compressionstring · two pointersEasy
- Is subsequencestring · two pointersEasy
- Palindrome after one deletionstring · two pointers · greedyEasy
- Counting bitsbit manipulation · dynamic programmingEasy
- Happy numbermath · hash set · fast and slow pointersEasy
- Gas stationgreedy · arrayMedium
- Car fleetsstack · sorting · monotonic stackMedium
- Largest rectangle in a histogramstack · monotonic stack · arrayHard
- Isomorphic stringsstring · hash mapEasy
- Fast powermath · recursion · divide and conquerMedium
- Top students in Cairosql · select · where · order byEasy
- Students per citysql · group by · countEasy
- Students with no enrollmentsql · left join · nullEasy
- Duplicate emailssql · group by · havingEasy
- Most popular coursesql · join · group by · subqueryEasy
- Second highest salarysql · subquery · limit offset · nullMedium
- Top earners per departmentsql · join · window functions · subqueryMedium
- Average score per coursesql · group by · having · aggregateMedium
- Running total of paymentssql · window functionsMedium
- Rank the scoressql · window functions · dense rankMedium
- Monthly revenuesql · group by · dates · whereMedium
- Managers with three or more reportssql · self join · group by · havingMedium
- Each customer's first ordersql · join · group by · aggregateMedium
- Three-day login streakssql · window functions · gaps and islands · datesHard
- Daily cancellation ratesql · join · group by · caseHard
- Top two salaries per departmentsql · window functions · dense rank · joinHard
- Course completion ratesql · group by · case · aggregateMedium