Algorithms interview questions
Practice 115 questions on algorithms. Each runs in a real in-browser editor with Jest tests and a worked, diagram-backed solution.
115 questions
- AlgorithmsCoding exercise
Bit Reversal
EASYImplement a function that reverses the order of the bits in the binary representation of a number.
15 minPractice - AlgorithmsCoding exercise
Bubble Sort
EASYImplement bubble sort, repeatedly swapping adjacent out-of-order pairs until the array is sorted.
15 minPractice - JavaScriptCoding exercise
Chunk
EASYImplement a function that splits an array into groups of a given size, with the last group holding the remainder.
15 minPractice - JavaScriptCoding exercise
Clamp
EASYImplement a function that constrains a number to lie within an inclusive minimum and maximum range.
15 minPractice - AlgorithmsCoding exercise
Count Set Bits in a Binary Number
EASYImplement a function that counts the number of 1 bits in the binary representation of an integer.
15 minPractice - AlgorithmsCoding exercise
Find Duplicates in Array
EASYImplement a function that checks whether an array contains any duplicate numbers.
15 minPractice - AlgorithmsCoding exercise
First Bad Version
EASYFind the first failing version among 1..n where a monotonic isBad check flips from false to true — a boundary binary search using the fewest checks.
15 minPractice - JavaScriptCoding exercise
In Range
EASYImplement a function that checks whether a number lies within a half-open range, swapping bounds when needed.
15 minPractice - AlgorithmsCoding exercise
Insertion Sort
EASYImplement insertion sort by building the sorted portion one element at a time from the input.
15 minPractice - AlgorithmsCoding exercise
Linked List Reversal
EASYImplement a function that reverses a singly linked list in place and returns the new head.
15 minPractice - JavaScriptCoding exercise
Mean
EASYImplement a function that computes the arithmetic mean of the numbers in an array.
15 minPractice - AlgorithmsCoding exercise
Meeting Calendar
EASYImplement a function that determines whether a person can attend every meeting given their time intervals.
15 minPractice - AlgorithmsCoding exercise
Move Zeroes
EASYMove all zeroes to the end of an array in place while keeping the non-zero elements in their original order.
20 minGoogle · MetaPractice - AlgorithmsCoding exercise
Optimal Stock Trading
EASYImplement a function that computes the maximum profit obtainable from one buy and one sell of a stock.
15 minPractice - JavaScriptCoding exercise
Range
EASYImplement a function that builds an array of numbers from start up to end, stepping by a given increment.
15 minPractice - JavaScriptCoding exercise
Range Right
EASYImplement a function that builds an array of numbers from end down to start in descending order.
15 minPractice - AlgorithmsCoding exercise
Selection Sort
EASYImplement selection sort to order an array by repeatedly picking the smallest remaining element.
15 minPractice - AlgorithmsCoding exercise
Staircase Climbing Combinations
EASYImplement a function that counts the distinct ways to climb to the top of a staircase taking one or two steps.
15 minPractice - AlgorithmsCoding exercise
String Anagram
EASYImplement a function that determines whether two strings are anagrams of each other.
15 minPractice - AlgorithmsCoding exercise
String Palindrome
EASYImplement a function that returns whether a string reads the same forwards and backwards.
15 minPractice - AlgorithmsCoding exercise
0/1 Knapsack
MEDIUMMaximize the value packed into a weight-limited knapsack when each item can be taken at most once — the classic 0/1 dynamic-programming table.
25 minPractice - JavaScriptCoding exercise
A/B Test Bucketing
MEDIUMAssign users to weighted experiment variants deterministically, with a traffic gate and independent buckets per experiment.
25 minPractice - JavaScriptCoding exercise
Arithmetic Expression Evaluator
MEDIUMTokenize and evaluate a math expression string with operator precedence, parentheses, and unary minus.
35 minAmazon · Google · MicrosoftPractice - JavaScriptCoding exercise
BigInt String Arithmetic
MEDIUMAdd and multiply arbitrarily large non-negative integers given as decimal strings, using digit-by-digit schoolbook arithmetic with carries.
25 minPremium questionPractice - AlgorithmsCoding exercise
Binary Search
MEDIUMImplement binary search on a sorted array, returning the index of the target or -1 when absent.
25 minPractice - AlgorithmsCoding exercise
Bit Counting
MEDIUMImplement a function that returns an array of set-bit counts for every integer from 0 up to n.
25 minPractice - AlgorithmsCoding exercise
Breadth-First Search
MEDIUMImplement breadth-first traversal of a directed graph, visiting nodes level by level from a start vertex.
25 minPractice - AlgorithmsCoding exercise
Combinations for Target Sum
MEDIUMImplement a function that returns every unique combination of reusable candidates that sums to a target.
25 minPractice - UI / FrameworksUI challenge4 variants
Connect Four
MEDIUMBuild a two-player Connect Four game where discs fall to the lowest empty slot and four-in-a-row wins.
25 minAirbnb · Meta · UberPractice - AlgorithmsCoding exercise
Count Islands in a Grid
MEDIUMImplement a function that counts the number of distinct islands of connected cells in a 2D binary grid.
25 minAdobePractice - AlgorithmsCoding exercise
Counting / Radix Sort
MEDIUMSort integers without comparisons — counting sort tallies occurrences into buckets, and radix sort applies it digit by digit from the least significant.
25 minPremium questionPractice - AlgorithmsCoding exercise
Course Dependency
MEDIUMImplement a function that decides whether a set of courses can be finished given their prerequisite pairs.
25 minPractice - AlgorithmsCoding exercise
Decode Message
MEDIUMImplement a function that counts how many ways a digit string can be decoded into letters using a 1 to 26 mapping.
25 minPractice - AlgorithmsCoding exercise
Delete Nth Node from End of Linked List
MEDIUMImplement a function that removes the nth-from-end node from a singly linked list in one pass.
25 minPractice - AlgorithmsCoding exercise
Depth-First Search
MEDIUMImplement depth-first traversal of a directed graph, exploring each branch fully before backtracking.
25 minPractice - AlgorithmsCoding exercise
Disjoint Intervals
MEDIUMImplement a function that returns the minimum number of intervals to remove so the remaining ones do not overlap.
25 minPractice - AlgorithmsCoding exercise
Distinct Paths in Grid
MEDIUMImplement a function that counts the number of unique paths a robot can take from the top-left to bottom-right of an m by n grid.
25 minPractice - AlgorithmsCoding exercise
Edit Distance
MEDIUMCompute the minimum number of insertions, deletions, and replacements to turn one string into another — the Levenshtein distance via a 2D dynamic-programming table.
25 minPractice - AlgorithmsCoding exercise
End of Array Reachable
MEDIUMImplement a function that decides whether you can reach the last index of an array using each element as a max jump.
25 minPractice - JavaScriptCoding exercise
Excel Column ↔ Number
MEDIUMConvert between Excel column titles and numbers in both directions — A is 1, Z is 26, AA is 27 — the classic bijective base-26 system with no zero digit.
25 minPremium questionPractice - AlgorithmsCoding exercise
Fast Power
MEDIUMRaise a base to an integer exponent in logarithmic time using exponentiation by squaring, handling negative exponents.
25 minPractice - JavaScriptCoding exercise
Feature Flag Client
MEDIUMEvaluate feature flags with targeting rules and a deterministic percentage rollout that stays sticky per user.
25 minPractice - AlgorithmsCoding exercise
Find the Longest Palindromic Substring
MEDIUMImplement a function that returns the longest palindromic substring contained within a given string.
25 minPractice - AlgorithmsCoding exercise
Find Word in Grid
MEDIUMImplement a function that checks whether a target word can be traced through adjacent cells in a 2D character grid.
25 minPractice - AlgorithmsCoding exercise
Generate Parentheses
MEDIUMGenerate every well-formed combination of n pairs of parentheses by backtracking — add an open bracket while any remain, and a close bracket only while it stays balanced.
25 minPractice - AlgorithmsCoding exercise
Graph Count Connected Components
MEDIUMImplement a function that counts the number of connected components in an undirected graph given its edges.
25 minPractice - JavaScriptCoding exercise
ICU Message Formatter
MEDIUMParse and format ICU MessageFormat strings with plural, select, and nested argument substitution.
25 minPractice - AlgorithmsCoding exercise
Integer Square Root
MEDIUMCompute the integer square root — the floor of the real square root — using Newton's method, without Math.sqrt.
25 minPremium questionPractice - AlgorithmsCoding exercise
Is the Graph a Tree
MEDIUMImplement a function that determines whether a given undirected graph forms a valid tree.
25 minPractice - AlgorithmsCoding exercise
Linked List Detect Cycle
MEDIUMImplement a function that detects whether a singly linked list contains a cycle.
25 minPractice - AlgorithmsCoding exercise
Longest Common Subsequence
MEDIUMImplement a function that returns the length of the longest subsequence common to two input strings.
25 minPractice - AlgorithmsCoding exercise
Longest Consecutive Number Sequence
MEDIUMImplement a function that returns the length of the longest run of consecutive integers found in an unsorted array.
25 minPractice - AlgorithmsCoding exercise
Longest Increasing Subsequence
MEDIUMImplement a function that returns the length of the longest strictly increasing subsequence in an array.
25 minUberPractice - AlgorithmsCoding exercise
Longest Non-repeating Substring
MEDIUMImplement a function that returns the length of the longest substring containing no duplicate characters.
25 minPractice - AlgorithmsCoding exercise
Matrix Spiral Traversal
MEDIUMImplement a function that walks a 2D matrix in clockwise spiral order and returns the visited values.
25 minPractice - AlgorithmsCoding exercise
Matrix Zeroing
MEDIUMImplement a function that zeroes out every row and column in a matrix that originally contained a zero, ideally in place.
25 minPractice - AlgorithmsCoding exercise
Maximal Square
MEDIUMFind the area of the largest all-ones square in a binary matrix, where each cell's square size is one more than the smallest of its top, left, and top-left neighbors.
25 minPremium questionPractice - AlgorithmsCoding exercise
Maximum Product in Contiguous Array
MEDIUMImplement a function that finds the contiguous subarray with the largest product, handling negatives and zeros.
25 minPractice - AlgorithmsCoding exercise
Maximum Sum in Contiguous Array
MEDIUMImplement a function that finds the contiguous subarray with the largest sum.
25 minPractice - AlgorithmsCoding exercise
Maximum Water Trapped Between Walls
MEDIUMImplement a function that finds the maximum amount of water that can be trapped between two walls.
25 minPractice - AlgorithmsCoding exercise
Merge New Interval
MEDIUMImplement a function that inserts a new interval into a sorted list and merges any resulting overlaps.
25 minPractice - AlgorithmsCoding exercise
Merge Overlapping Intervals
MEDIUMImplement a function that merges all overlapping intervals in a list and returns the consolidated set in sorted order.
25 minPractice - AlgorithmsCoding exercise
Merge Sort
MEDIUMImplement merge sort recursively by splitting the array and merging the sorted halves back together.
25 minPractice - AlgorithmsCoding exercise
Minimum Coins for Change
MEDIUMImplement a function that returns the fewest coins needed to make a target amount, or -1 when no combination works.
25 minPractice - AlgorithmsCoding exercise
Minimum Meeting Rooms Needed
MEDIUMImplement a function that returns the fewest meeting rooms required to host a list of time intervals without conflicts.
25 minPractice - AlgorithmsCoding exercise
Minimum Path Sum
MEDIUMFind the cheapest path from the top-left to the bottom-right of a grid, moving only right or down, by summing each cell with the smaller of the two ways to reach it.
25 minPremium questionPractice - AlgorithmsCoding exercise
Most Common Elements
MEDIUMImplement a function that returns the k most frequent integers in an array, breaking ties consistently.
25 minNetflixPractice - AlgorithmsCoding exercise
Neighborhood Theft
MEDIUMImplement a function that computes the maximum money you can rob from a row of houses without picking two adjacent ones.
25 minPractice - AlgorithmsCoding exercise
Neighborhood Theft (Circular)
MEDIUMImplement a function that maximizes loot from houses arranged in a circle without robbing two adjacent ones.
25 minPractice - AlgorithmsCoding exercise
Ocean Flow
MEDIUMImplement a function that returns every grid cell from which water can flow to both the Pacific and Atlantic oceans.
25 minPractice - AlgorithmsCoding exercise
Palindrome Partitioning
MEDIUMSplit a string every possible way so that each piece is a palindrome — backtrack over cut positions, extending a piece only while it reads the same both ways.
25 minPractice - AlgorithmsCoding exercise
Palindromic Substrings
MEDIUMImplement a function that counts every palindromic substring within a string, including overlapping occurrences.
25 minPractice - AlgorithmsCoding exercise
Partition Equal Subset Sum
MEDIUMDecide whether an array can split into two subsets with equal sums — a subset-sum dynamic-programming problem over half the total.
25 minPremium questionPractice - AlgorithmsCoding exercise
Permutations & Subsets
MEDIUMGenerate every permutation and every subset of an array with the same backtracking template — choose, recurse, and undo.
25 minPractice - AlgorithmsCoding exercise
Phone Letter Combinations
MEDIUMList every letter string a phone number could spell, mapping each digit to its keypad letters and backtracking through the choices.
25 minPractice - AlgorithmsCoding exercise
Prime Check / Sieve
MEDIUMTest whether a number is prime and generate all primes up to n with the Sieve of Eratosthenes.
25 minPremium questionPractice - AlgorithmsCoding exercise
Quick Sort
MEDIUMImplement quick sort recursively, partitioning around a pivot and sorting each side independently.
25 minPractice - AlgorithmsCoding exercise
Quickselect
MEDIUMFind the k-th smallest element of an unsorted array in average linear time by partitioning, without fully sorting it.
25 minPremium questionPractice - JavaScriptCoding exercise
Rate Limiter
MEDIUMImplement a sliding-window rate limiter that decides which task timestamps fit within the allowed quota.
25 minAnthropic · Stripe · UberPractice - AlgorithmsCoding exercise
Reading Order
MEDIUMImplement a function that sorts positioned canvas elements into natural left-to-right, top-to-bottom reading order.
25 minFigmaPractice - AlgorithmsCoding exercise
Reading Order II
MEDIUMImplement a function that groups misaligned 2D canvas elements into rows, then sorts them into a natural reading order.
25 minPremium questionFigmaPractice - AlgorithmsCoding exercise
Rearrange Linked List
MEDIUMImplement a function that reorders a singly linked list by interleaving nodes from the front and the reversed back half.
25 minPractice - JavaScriptCoding exercise
Roman Numerals ↔ Integer
MEDIUMConvert between Roman numerals and integers in both directions, handling subtractive notation like IV, IX, and XL.
25 minPremium questionPractice - JavaScriptCoding exercise
Run-Length Encoding
MEDIUMImplement run-length encoding: compress runs of repeated characters into count+char pairs, and decode them back.
25 minPremium questionPractice - AlgorithmsCoding exercise
Search a 2D Matrix
MEDIUMSearch a matrix whose rows and columns are both sorted by walking a staircase from the top-right corner, eliminating a whole row or column at each step.
25 minPremium questionPractice - JavaScriptCoding exercise
Shuffle / Sample Size
MEDIUMImplement lodash shuffle and sampleSize with an unbiased Fisher-Yates swap, taking an injectable RNG so shuffles are testable.
30 minPremium questionPractice - AlgorithmsCoding exercise
String Anagram Groups
MEDIUMImplement a function that groups an array of strings so anagrams of each other end up in the same bucket.
25 minAmazonPractice - JavaScriptCoding exercise
Styled Text Ranges II
MEDIUMImplement a function that overwrites the style on a given text range and normalizes the resulting range list.
25 minPremium questionFigmaPractice - AlgorithmsCoding exercise
Sum Without Addition
MEDIUMImplement a function that adds two integers using only bitwise operators, without using + or -.
25 minPractice - AlgorithmsCoding exercise
Task Coordination
MEDIUMImplement a function that schedules tasks with a cooldown between identical ones and returns the minimum total time.
25 minPractice - UI / FrameworksUI challenge4 variants
Tic-tac-toe
MEDIUMBuild a two-player tic-tac-toe game that detects wins and draws on a 3x3 board.
25 minAirbnb · Amazon · Apple +6Practice - AlgorithmsCoding exercise
Triplet Sum
MEDIUMImplement a function that returns every unique triplet of distinct indices whose values sum to zero.
25 minPractice - AlgorithmsCoding exercise
Union-Find (Disjoint Set)
MEDIUMBuild a disjoint-set structure with near-constant-time union and find, using path compression and union by rank to keep the trees flat.
25 minPractice - JavaScriptCoding exercise
Vector Clocks
MEDIUMOrder distributed events with vector clocks, detecting whether two events are causal or concurrent.
25 minPractice - AlgorithmsCoding exercise
Dijkstra's Algorithm
HARDImplement Dijkstra's algorithm to compute shortest paths from a source vertex in a weighted graph.
40 minPremium questionPractice - AlgorithmsCoding exercise
Extraterrestrial Language
HARDGiven words sorted in an unknown alphabet's order, reconstruct the alphabet.
40 minAirbnb · Facebook · GooglePractice - AlgorithmsCoding exercise
Find Words in Grid
HARDImplement a function that returns every word from a dictionary that can be traced through adjacent cells in a grid.
40 minPremium questionPractice - AlgorithmsCoding exercise
Heap Sort
HARDImplement heap sort by building a max-heap and repeatedly extracting the largest element.
40 minPremium questionPractice - AlgorithmsCoding exercise
Median of Two Sorted Arrays
HARDFind the median of two sorted arrays in logarithmic time by binary-searching for the partition that splits all the elements into equal halves.
40 minPremium questionPractice - UI / FrameworksUI challenge4 variants
Minesweeper
HARDBuild Minesweeper with flood-fill reveal, flagging, and win/lose detection.
40 minPremium questionPractice - AlgorithmsCoding exercise
N-Queens
HARDPlace N queens on an N×N board so none attack another — a classic backtracking search that places one queen per row and prunes column and diagonal conflicts.
40 minPremium questionPractice - AlgorithmsCoding exercise
Number Stream Median
HARDImplement a data structure that ingests integers one at a time and reports the running median in logarithmic time.
40 minPremium questionPractice - JavaScriptCoding exercise
Operational Transform (Text)
HARDTransform concurrent insert and delete operations so replicas converge to the same text.
40 minPremium questionPractice - JavaScriptCoding exercise
Rich Text to HTML
HARDImplement a function that converts a list of styled text ranges into a canonical, properly nested HTML string.
40 minPremium questionMetaPractice - AlgorithmsCoding exercise
Shortest Substring Containing Characters
HARDImplement a function that returns the smallest window of a string that contains every character of another string.
40 minPremium questionPractice - JavaScriptCoding exercise
Spreadsheet III
HARDBuild a spreadsheet that recomputes dependent cells when inputs change and detects circular references.
40 minPremium questionDiscord · OpenAIPractice - JavaScriptCoding exercise
Statechart Engine (XState-lite)
HARDBuild a state-machine engine with events, guards, entry and exit actions, and context updates.
40 minPremium questionPractice - JavaScriptCoding exercise
Styled Text Ranges
HARDImplement a slice operation over text annotated with overlapping style ranges, preserving alignment.
40 minPremium questionFigmaPractice - JavaScriptCoding exercise
Styled Text Ranges III
HARDImplement a function that replaces a text range and keeps the surrounding style ranges normalized.
40 minPremium questionFigmaPractice - JavaScriptCoding exercise
Styled Text Ranges IV
HARDImplement a function that patches shallow style objects over a text range without clobbering unrelated keys.
40 minPremium questionFigmaPractice - AlgorithmsCoding exercise
Sudoku Solver
HARDFill a 9×9 Sudoku grid by backtracking — try each digit in the next empty cell, checking its row, column, and 3×3 box, and undo on a dead end.
40 minPremium questionPractice - UI / FrameworksUI challenge4 variants
Tic-tac-toe II
HARDBuild a generalized tic-tac-toe game on an N x N board where M consecutive marks wins.
40 minAmazon · Apollo · Apple +4Practice - AlgorithmsCoding exercise
Topological Sort
HARDImplement a function that returns a topological ordering of nodes in a directed acyclic graph.
40 minPremium questionSnapPractice - AlgorithmsCoding exercise
Wildcard Matching
HARDDecide whether a string matches a pattern containing `?` (any single character) and `*` (any sequence) — a two-dimensional dynamic-programming match over string and pattern.
40 minPremium questionPractice - UI / FrameworksUI challenge4 variants
Wordle
HARDBuild the Wordle word-guessing game with row-by-row guesses and per-letter color feedback.
40 minRamp · TekionPractice