Coding interview problems
Practice 45 classic coding interview problems in Python and JavaScript. Run your code against real test cases in the browser, then read the step-by-step solutions with time & space complexity.
Your progress
0 / 45 solved
45 problems
Two Sum
Two Sum: finding two numbers in an array that add up to a given target number
Merge Intervals
Given a collection of intervals, merge any overlapping intervals.
Reverse a String
reverse a string interview question
Longest Common Prefix
Find the longest common prefix string amongst an array of strings.
Palindrome String
Palindrome String: Free. No login required. Python technical interview question
Roman to Integer
Given a Roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.
Letter Combinations of a Phone Number
Write a function to generate all possible combinations of letters that can be formed from a given string of digits representing a phone number.
Valid Parentheses
valid parentheses coding question
Find the Index of the First Occurrence in a String
Learn how to find the index of the first occurrence of a substring in a string in this coding interview problem.
Length of Last Word
Find the length of the last word in a given string.
Spiral Matrix
given number n return matrix n by n with numbers in spiral order
FizzBuzz
Classic FizzBuzz: return a list from 1 to n with Fizz/Buzz substitutions.
Contains Duplicate
Return true if any value appears at least twice in the array.
Maximum Subarray
Find the contiguous subarray with the largest sum and return that sum.
Fibonacci Number
Return the nth Fibonacci number (0-indexed).
Factorial
Compute n! (the factorial of a non-negative integer n).
Move Zeroes
Move all zeroes to the end while keeping the order of non-zero elements.
Single Number
Every element appears twice except one. Find the single one.
Best Time to Buy and Sell Stock
Maximize profit from a single buy/sell of a stock given daily prices.
Valid Anagram
Determine whether one string is an anagram of another.
Binary Search
Return the index of target in a sorted array, or -1 if not present.
Count Vowels
Count the number of vowels in a string.
Climbing Stairs
Count distinct ways to climb n stairs taking 1 or 2 steps at a time.
Product of Array Except Self
Return an array where each element is the product of all others.
Trapping Rain Water
Given an elevation map, compute how much water it can trap after raining.
Edit Distance
Find the minimum number of edit operations to convert one word into another.
Median of Two Sorted Arrays
Find the median of two sorted arrays in logarithmic time.
Longest Valid Parentheses
Find the length of the longest valid well-formed parentheses substring.
Palindrome Number
Determine whether an integer reads the same backward as forward.
Plus One
Add one to a number represented as an array of digits.
Majority Element
Find the element that appears more than half the time in an array.
Is Subsequence
Check whether one string is a subsequence of another.
First Unique Character in a String
Find the index of the first non-repeating character in a string.
Search Insert Position
Return the index where a target should be inserted into a sorted array.
House Robber
Maximize the loot from non-adjacent houses along a street.
Jump Game
Decide whether you can reach the last index of an array of jump lengths.
Coin Change
Find the fewest coins needed to make up a given amount.
Longest Substring Without Repeating Characters
Find the length of the longest substring without repeating characters.
Container With Most Water
Find two lines that together with the x-axis hold the most water.
Number of Islands
Count the number of islands in a grid of land and water cells.
Word Break
Determine whether a string can be segmented into words from a dictionary.
Longest Increasing Subsequence
Find the length of the longest strictly increasing subsequence.
Largest Rectangle in Histogram
Find the area of the largest rectangle that fits under a histogram.
Sliding Window Maximum
Return the maximum of every contiguous window of size k.
Jump Game II
Find the minimum number of jumps needed to reach the last index.