String Questions20 questionsPalindromes, sliding windows, anagrams and parsing.Array Questions10 questionsTwo pointers, prefix sums and arrays.Hash Maps10 questionsCounting, sets, fast lookups and cache design.Linked Lists10 questionsPointer manipulation, cycles and merging.Sorting & Searching10 questionsBinary search, sorting and intervals.Recursion10 questionsBase cases, backtracking and recursive reasoning.Trees & Graphs10 questionsTraversals, graph connectivity, DFS and BFS.Dynamic Programming13 questionsOptimisation, memoisation and tabulation.
String Questions
Palindromes, sliding windows, anagrams and parsing.
1Reverse a StringReverse the characters in a string.Practice2Check a PalindromeReturn true if a string reads the same forwards and backwards.Practice3First Non-Repeating CharacterReturn the first character appearing only once, or an empty string.Practice4Valid AnagramDetermine whether two strings have exactly the same characters with the same frequencies.Practice5Longest Substring Without RepeatsFind the length of the longest substring containing no repeated characters.Practice6Longest Palindromic SubstringReturn the longest contiguous palindrome; for ties, return the earliest.Practice7String to Integer (atoi)Convert a string to a signed 32-bit integer, stopping at the first invalid character.Practice8Implement strStr()Find the index of the first occurrence of a substring, or -1.Practice9Longest Common PrefixFind the longest prefix shared by all strings in the array.Practice10Valid ParenthesesValidate matching parentheses, square brackets and curly braces.Practice11Group AnagramsGroup words that contain the same letters. Return groups ordered by first occurrence.Practice12Length of Last WordReturn the length of the last word, ignoring trailing spaces.Practice13Reverse Words in a StringReverse the order of words and normalise spaces.Practice14Repeated DNA SequencesReturn repeated 10-character DNA substrings in first-repeat order.Practice15Count and SayReturn the nth term of the Count and Say sequence (n starts at 1).Practice16Roman to IntegerConvert a valid Roman numeral to an integer.Practice17Integer to RomanConvert an integer from 1 through 3999 to Roman numerals.Practice18Zigzag ConversionWrite characters in zigzag rows and read them row by row.Practice19Minimum Window SubstringFind the shortest substring containing all target characters with multiplicity.Practice20Add Binary StringsAdd two binary strings and return the binary sum.Practice
Array Questions
Two pointers, prefix sums and arrays.
1Two SumReturn the two distinct indexes whose values add up to the target. Exactly one solution exists. Use ascending index order.Practice2Maximum Subarray (Kadane)Return the greatest sum of any nonempty contiguous subarray.Practice3Move ZeroesMove all zeros to the end while preserving the order of other values. Return the modified array.Practice4Contains DuplicateReturn true if at least one value occurs more than once.Practice5Merge Sorted ArraysMerge two individually sorted numeric arrays into one sorted array.Practice6Best Time to Buy and Sell StockReturn the maximum nonnegative profit from one buy followed by one sale.Practice7Product Except SelfReturn an array where each element equals the product of every other element.Practice8Rotate ArrayRotate an array right by k positions and return the result.Practice9Majority ElementReturn the value appearing more than half the time. A majority is guaranteed.Practice10Subarray Sum Equals KCount contiguous subarrays whose sum equals the given target.Practice
Hash Maps
Counting, sets, fast lookups and cache design.
1First Non-Repeating CharacterReturn the first character appearing only once, or an empty string.Practice2Subarray Sum Equals KCount contiguous subarrays whose sum equals the given target.Practice3Intersection of Two ArraysReturn the distinct values appearing in both input arrays.Practice4Most Frequent ElementReturn the most frequent value; break ties by smallest numeric value.Practice5Top K Frequent ElementsReturn k most frequent numbers; break ties by ascending numeric order.Practice6Longest Consecutive SequenceFind the longest run of consecutive integer values in an unsorted array.Practice7Isomorphic StringsCheck whether characters in two strings form a consistent one-to-one mapping.Practice8Word PatternCheck whether a space-separated sentence follows a character pattern.Practice9Design a Basic Hash MapProcess put, get and remove operations. Return the results of get operations; return -1 for missing keys.Practice10LRU CacheSimulate a least-recently-used cache and return values for get operations.Practice
Linked Lists
Pointer manipulation, cycles and merging.
1Reverse a Linked ListReverse the links in a singly linked list. Input/output use an array to represent node order.Practice2Detect a Linked List CycleGiven node values and the index the tail connects to (-1 for none), decide whether a cycle exists.Practice3Merge Two Sorted Linked ListsMerge two sorted linked lists. Input and output are serialized as arrays.Practice4Middle of Linked ListReturn the value of the middle node. For even lengths, return the second middle node.Practice5Remove Nth Node From EndRemove the nth node from the end of a linked list, represented as an array.Practice6Add Two Numbers as Linked ListsEach linked list stores a reversed sequence of decimal digits; return the sum in the same format.Practice7Palindrome Linked ListReturn true if the linked-list node values read the same forwards and backwards.Practice8Intersection of Two Linked ListsTwo chains share a common tail. Return the first shared node value, or null. The shared tail is supplied explicitly.Practice9Reorder Linked ListReorder nodes as first, last, second, second-last, and so on.Practice10Reverse Nodes in K GroupReverse linked-list nodes in groups of size k; leave a final short group unchanged.Practice
Sorting & Searching
Binary search, sorting and intervals.
1Binary SearchFind the index of a target in a sorted array, or -1 if absent.Practice2Merge SortReturn a sorted copy using the merge sort divide-and-conquer algorithm.Practice3Quick SortReturn a sorted copy using quicksort partitioning.Practice4Search Rotated Sorted ArrayReturn a target index in a rotated sorted array with distinct values, or -1.Practice5First and Last Position in Sorted ArrayReturn the starting and ending indices of a target, or [-1,-1].Practice6Find Peak ElementReturn the index of any element strictly greater than its neighbours.Practice7Kth Largest ElementReturn the kth largest array element, counting duplicate values.Practice8Minimum in Rotated Sorted ArrayFind the minimum number in a rotated sorted array of distinct integers.Practice9Merge Overlapping IntervalsMerge closed intervals that overlap or share a boundary.Practice10Sort Colors (0s, 1s, 2s)Sort an array containing only the values 0, 1 and 2.Practice
Recursion
Base cases, backtracking and recursive reasoning.
1Factorial Using RecursionCompute n! for a nonnegative integer n.Practice2Fibonacci NumberReturn F(n), where F(0)=0, F(1)=1 and F(n)=F(n-1)+F(n-2).Practice3Sum of Digits Using RecursionCalculate the sum of decimal digits in a nonnegative integer.Practice4Reverse a String Using RecursionReverse a string using recursive calls.Practice5Pow(x, n) Using Fast RecursionCompute x raised to an integer power n.Practice6Generate All SubsetsReturn every subset of a list of distinct integers, ordered by increasing subset size then lexicographically.Practice7Generate All PermutationsReturn every permutation of distinct integers in lexicographical order.Practice8Generate Valid ParenthesesReturn valid combinations of n pairs of parentheses in lexicographic order.Practice9Tower of HanoiReturn the moves needed to transfer n discs from peg A to C using peg B.Practice10N QueensReturn all valid board arrangements for n queens, in deterministic row-by-row order.Practice
Trees & Graphs
Traversals, graph connectivity, DFS and BFS.
1Maximum Depth of Binary TreeFind the maximum root-to-leaf depth of a binary tree represented as a level-order array with nulls.Practice2Binary Tree Inorder TraversalReturn inorder values (left, root, right) for a binary tree in level-order array form.Practice3Binary Tree Level Order TraversalReturn tree node values grouped by level, using a complete-index level-order array.Practice4Same Binary TreeReturn true if two trees have identical structures and values. Trees use complete-index arrays with nulls.Practice5Validate Binary Search TreeReturn true if the binary tree satisfies strict BST ordering. Input is a complete-index array with nulls.Practice6Lowest Common Ancestor in a BSTReturn the lowest common ancestor value of p and q in a BST.Practice7Number of IslandsCount connected groups of 1s in a binary grid, using horizontal and vertical neighbours.Practice8Clone an Undirected GraphReturn a deep copy of a graph expressed as an adjacency list (each index represents a node).Practice9Cycle in a Directed GraphReturn true if a directed graph adjacency list contains a cycle.Practice10Shortest Path in Unweighted GraphReturn the shortest path length between nodes in an unweighted adjacency list, or -1.Practice
Dynamic Programming
Optimisation, memoisation and tabulation.
1Maximum Subarray (Kadane)Return the greatest sum of any nonempty contiguous subarray.Practice2Fibonacci NumberReturn F(n), where F(0)=0, F(1)=1 and F(n)=F(n-1)+F(n-2).Practice3Climbing StairsCount ways to climb n stairs when each step climbs one or two stairs.Practice4Minimum Cost Climbing StairsGiven the price of stepping on each stair, find the minimum cost to reach the top.Practice5House RobberMaximise the money taken from non-adjacent houses.Practice6Coin Change — Minimum CoinsReturn the fewest coins summing to amount, or -1 if impossible.Practice7Longest Increasing SubsequenceReturn the length of the longest strictly increasing subsequence.Practice8Longest Common SubsequenceReturn the length of the longest subsequence common to both strings.Practice9Unique Paths in GridCount paths from the top-left to bottom-right of an m by n grid, moving only right or down.Practice10Word BreakDetermine whether a string can be segmented into words from a given dictionary.Practice11Partition Equal Subset SumDetermine whether the array can be split into two subsets with equal sums.Practice12Edit DistanceFind minimum single-character insertions, deletions and substitutions to transform one string into another.Practice13Subset Sum ProblemGiven nonnegative integers and a target sum, determine whether some subset sums exactly to that target.Practice
Your drafts and progress stay in your browser. No sign-in needed. Results are intended for learning, not secure competitive grading.