Interview questions
Find a company or topic. Read the sources, then practice.
Loading the question library…
Find a company or topic. Read the sources, then practice.
Loading the question library…
Showing 26–39
Partition the array so that all even numbers appear before all odd numbers, returning any arrangement that satisfies this; order within the even/odd groups doesn't…
Companies: Meta, Zoho
Array · Sorting · Two Pointers
Last reported Jan 2025
Reorder an array of values 0, 1, and 2 in-place so all 0s come first, then 1s, then 2s (the Dutch National Flag problem); aim…
Companies: Amazon, Google, Microsoft, Walmart Labs
Array · Bubble Sort · Quicksort · Sorting
Last reported Oct 2024
Given an integer array and a target, find three numbers whose sum is closest to the target (unique solution guaranteed) and return that sum. This…
Companies: Bloomberg
Array · Sorting · Two Pointers
Find all unique quadruplets of distinct elements in an integer array whose values sum to a given target. Results must avoid duplicates (order irrelevant); with…
Companies: Oracle
Array · Sorting · Two Pointers
Given two equal-length arrays, permute nums1 to maximize the number of positions where nums1[i] > nums2[i]. This is a greedy matching problem: sort nums1 and…
Companies: Walmart Labs
Array · Greedy · Sorting · Two Pointers
Given heights of vertical lines at unit-spaced x-coordinates, pick two indices i<j to maximize the area min(height[i],height[j])*(j-i). With n up to 1e5, the problem requires…
Companies: Amazon, Bloomberg, Cisco, Flipkart +4
Array · Greedy · Two Pointers
Count the non-empty substrings of a binary string that contain an equal number of 0s and 1s with all 0s and all 1s each grouped…
Companies: D. E. Shaw
String · Two Pointers
Given two strings, return the starting index of the first occurrence of needle in haystack, or -1 if absent. This is a classic substring search…
Companies: Bloomberg, Google, Meta, Microsoft
Boyer–Moore String-Search Algorithm · Knuth–Morris–Pratt Algorithm · String · String Matching
Given positions of houses and heaters on a line, find the minimum uniform radius R such that every house is within distance R of some…
Companies: Anduril
Array · Binary Search · Sorting · Two Pointers
Companies: Amazon, NVIDIA
Floyd's Cycle Finding Algorithm · Hash Table · Linked List · Two Pointers
Partition the 2n integers into two equal-sized groups (choose n elements for one group) to minimize the absolute difference of their sums — a constrained…
Companies: Salesforce
Array · Binary Search · Bit Manipulation · Bitmask
Given a line of dominoes where some are initially pushed left (L), right (R), or upright (.), compute the final positions after simultaneous propagation of…
Companies: Anduril
Dynamic Programming · String · Two Pointers
Reverse the input array of characters in-place (O(1) extra space) so the characters appear in reverse order; array length can be up to 10^5.
Companies: Meta
String · Two Pointers
Count the number of triplets (i, j, k) from nums that can form triangle side lengths — i.e., three values a ≤ b ≤ c…
Companies: Bloomberg
Array · Binary Search · Greedy · Sorting