Coding interview problems
3,736 problems: 937 Easy, 1,914 Medium, 885 Hard. Each runs against hidden tests, in 13 languages; database problems in SQL. Free for members.
Solve them in the app Explore guides
Problems 1,901–2,000 of 3,736
- 1901. Rebalance a Lopsided BST Medium · Tree, Binary Search Tree, Binary Tree, Divide and Conquer
- 1902. Biggest Valid BST Inside a Tree Medium · Tree, Binary Tree, Binary Search Tree, Depth-First Search
- 1903. Count a Complete Tree Fast Medium · Tree, Binary Tree, Binary Search
- 1904. Balanced BST from a Sorted Chain Medium · Tree, Binary Search Tree, Linked List, Divide and Conquer
- 1905. Prune Weak Branches Medium · Tree, Binary Tree, Depth-First Search
- 1906. Strip Target Leaves Until None Remain Medium · Tree, Binary Tree, Depth-First Search
- 1907. Count Uniform Subtrees Medium · Tree, Binary Tree, Depth-First Search
- 1908. Peel the Tree Leaf Layer by Layer Medium · Tree, Binary Tree, Depth-First Search
- 1909. Nearest Leaf to a Marked Node Medium · Tree, Binary Tree, Breadth-First Search, Hash Table
- 1910. Can the Second Painter Win Medium · Tree, Binary Tree, Depth-First Search
- 1911. Does the Sequence Trace a Branch Medium · Tree, Binary Tree, Depth-First Search
- 1912. Subtree with the Highest Average Medium · Tree, Binary Tree, Depth-First Search
- 1913. Nodes Equal to Their Descendants' Total Medium · Tree, Binary Tree, Depth-First Search
- 1914. A Chain Hidden Along a Downward Path Medium · Tree, Binary Tree, Linked List, Depth-First Search
- 1915. Turn a Left-Leaning Tree Upside Down Medium · Tree, Binary Tree, Recursion
- 1916. Is the Comma String a Valid Preorder Medium · Tree, Stack, String
- 1917. Assemble a Tree from Parent-Child Records Medium · Tree, Binary Tree, Hash Table
- 1918. Rebuild from In-Order and Row Order Medium · Tree, Binary Tree, Divide and Conquer, Hash Table
- 1919. Parenthesise a Postfix Expression Medium · Tree, Stack, String
- 1920. Parse a Bracketed Tree Medium · Tree, Binary Tree, String, Stack
- 1921. Shared Ancestor in a Sorted Tree Medium · Tree, Binary Search Tree, Binary Tree
- 1922. Shared Ancestor of a Whole Group Medium · Tree, Binary Tree, Depth-First Search, Hash Table
- 1923. Same Tags, Different Shapes Medium · Tree, Binary Search Tree, Stack, Two Pointers
- 1924. Middle Tag of a BST Medium · Tree, Binary Search Tree, Binary Tree, Depth-First Search
- 1925. Rows of a Many-Child Tree Medium · Tree, Breadth-First Search
- 1926. Time for News to Reach Everyone Medium · Tree, Depth-First Search, Breadth-First Search, Graph
- 1927. Shut Down a Process Tree Medium · Tree, Breadth-First Search, Hash Table
- 1928. Line of Succession Medium · Tree, Depth-First Search, Design
- 1929. Is This Network a Tree Medium · Tree, Graph, Union Find
- 1930. Do These Child Links Form One Binary Tree Medium · Tree, Binary Tree, Graph, Union Find
- 1931. Same Org Chart Up to Reordering Medium · Tree, Hash Table, Depth-First Search
- 1932. Most Damaging Node to Remove Medium · Tree, Depth-First Search, Array
- 1933. Gather All Marked Nodes and Return Medium · Tree, Depth-First Search, Graph
- 1934. Same-Letter Descendants Medium · Tree, Depth-First Search, Hash Table, Counting
- 1935. Best Roots for a Short Tree Medium · Tree, Graph, Breadth-First Search, Topological Sort
- 1936. Longest Trail in a Park Medium · Tree, Graph, Depth-First Search, Breadth-First Search
- 1937. Party Without Direct Bosses Medium · Tree, Dynamic Programming, Depth-First Search
- 1938. Guard Every Corridor Medium · Tree, Dynamic Programming, Depth-First Search, Graph
- 1939. Farthest Distance from Every Node Medium · Tree, Depth-First Search, Dynamic Programming
- 1940. Sum of All Pairwise Hops Medium · Tree, Depth-First Search, Math
- 1941. Nearest Shop for Every House Medium · Tree, Breadth-First Search, Graph
- 1942. Count Calm Selections Medium · Tree, Dynamic Programming, Depth-First Search
- 1943. Count Connected Clusters Medium · Tree, Dynamic Programming, Depth-First Search
- 1944. Pair Up Neighbours Medium · Tree, Greedy, Depth-First Search
- 1945. Leaf Pairs Within Reach Medium · Tree, Binary Tree, Depth-First Search
- 1946. Equalise Every Root-to-Leaf Cost Medium · Tree, Binary Tree, Greedy, Array
- 1947. Cheapest Product Tree over a Row Medium · Tree, Dynamic Programming, Monotonic Stack, Greedy
- 1948. Total Cost of an Optimal Prefix Code Medium · Tree, Heap (Priority Queue), Greedy
- 1949. Factor Trees from a Set Medium · Tree, Hash Table, Dynamic Programming, Sorting
- 1950. Prefix Dictionary Operations Medium · Trie, Design, String
- 1951. Dictionary with Wildcard Lookups Medium · Trie, Design, Depth-First Search
- 1952. Shorten Words to Their Stems Medium · Trie, String
- 1953. Longest Word Grown Letter by Letter Medium · Trie, String, Hash Table
- 1954. Count Distinct Substrings Medium · Trie, String
- 1955. Count Misplaced Nodes Medium · Tree, Binary Tree, Binary Search Tree, Depth-First Search
- 1956. Shortest Suffix-Sharing Encoding Medium · Trie, String, Hash Table
- 1957. Drop Nested Folders Medium · Trie, String, Sorting
- 1958. Capital-Letter Pattern Match Medium · Trie, String, Two Pointers
- 1959. Fewest Swaps to a Search Tree Medium · Array, Tree, Binary Search Tree, Binary Tree, Sorting
- 1960. Numbers 1..n in Dictionary Order Medium · Trie, Depth-First Search
- 1961. Longest Prefix Shared by Any Pair Medium · Trie, String, Sorting
- 1962. Banner Row Symbol Medium · Math, Bit Manipulation, Recursion, Tree
- 1963. Shortest Distinguishing Prefixes Medium · Trie, String
- 1964. Editable Range Totals Medium · Tree, Array, Design, Prefix Sum
- 1965. Live Minimum over Ranges Medium · Tree, Array, Design, Divide and Conquer
- 1966. Count Out-of-Order Pairs Medium · Tree, Array, Divide and Conquer, Sorting
- 1967. Quadtree Leaves for a Grid Medium · Tree, Divide and Conquer, Math, Array
- 1968. List Every Ancestor Easy · Tree, Depth-First Search, Hash Table
- 1969. Best Short Downward Run Medium · Tree, Binary Tree, Depth-First Search
- 1970. Chain of Command Lengths Medium · Tree, Array, Memoization
- 1971. Pair Sum on One Level Easy · Tree, Binary Tree, Breadth-First Search, Hash Table
- 1972. Strongest Branch Signature Easy · Tree, Binary Tree, Depth-First Search, Bit Manipulation
- 1973. Alternating Sum Across Each Row Easy · Tree, Binary Tree, Breadth-First Search
- 1974. Median of Each Row Easy · Tree, Binary Tree, Breadth-First Search, Sorting
- 1975. Nodes k Above a Leaf Medium · Tree, Binary Tree, Depth-First Search
- 1976. Is the Mirror a BST in Reverse Medium · Tree, Binary Search Tree, Binary Tree, Depth-First Search
- 1977. Same Values, Mirrored Rows Medium · Tree, Binary Tree, Breadth-First Search
- 1978. Keep Filling a Complete Tree Medium · Tree, Binary Tree, Breadth-First Search, Queue, Design
- 1979. Rows of a BST Built by Insertions Medium · Tree, Binary Search Tree, Breadth-First Search
- 1980. Kth Largest Value in a Plain Tree Medium · Tree, Binary Tree, Heap (Priority Queue)
- 1981. Smallest Subtree Covering a Range Medium · Tree, Binary Search Tree, Binary Tree
- 1982. Delete a Whole Range from a BST Medium · Tree, Binary Search Tree, Binary Tree, Depth-First Search
- 1983. Sum of Every Branch's Maximum Medium · Tree, Binary Tree, Depth-First Search
- 1984. Twin Subtrees Under One Node Medium · Tree, Binary Tree, Depth-First Search, Hash Table
- 1985. Most Distinct Values on a Branch Medium · Tree, Binary Tree, Depth-First Search, Hash Table
- 1986. Cheapest Clash-Free Painting Hard · Tree, Dynamic Programming, Depth-First Search
- 1987. BST Pairs Below a Bound Medium · Tree, Binary Search Tree, Binary Tree, Two Pointers
- 1988. Tree from a Depth Sequence Medium · Tree, Binary Tree, Stack
- 1989. Round-Trip a Tree Through Text Hard · Tree, Binary Tree, Design, String
- 1990. Rebuild from a Dash-Indented Outline Medium · Tree, Binary Tree, Stack, String
- 1991. Any-Shape Paths with a Target Sum Hard · Tree, Binary Tree, Depth-First Search, Hash Table
- 1992. Height After Removing a Subtree Hard · Tree, Binary Tree, Depth-First Search, Array
- 1993. Richest BST Inside a Tree Hard · Tree, Binary Tree, Binary Search Tree, Depth-First Search, Dynamic Programming
- 1994. Fewest Leaf Flips to Change the Verdict Hard · Tree, Binary Tree, Depth-First Search, Dynamic Programming
- 1995. Cheapest Search Tree for Known Frequencies Hard · Tree, Binary Search Tree, Dynamic Programming, Array
- 1996. Shapes of Exact Height Hard · Tree, Binary Tree, Dynamic Programming, Math
- 1997. Balanced Shapes of Height h Medium · Tree, Binary Tree, Dynamic Programming, Math
- 1998. Total Distance from Every Node Hard · Tree, Depth-First Search, Dynamic Programming, Graph
- 1999. Ancestor Jumps Hard · Tree, Depth-First Search, Binary Search, Bit Manipulation, Design
- 2000. Many Shared-Ancestor Queries Hard · Tree, Depth-First Search, Bit Manipulation