Arrays interview questions
Practice 12 questions on arrays. Each runs in a real in-browser editor with Jest tests and a worked, diagram-backed solution.
12 questions
- EASY
Array XOR (Symmetric Difference)
Implement lodash xor — return the values that appear in exactly one of the given arrays, with duplicates removed.
20 minJavaScript - EASY
First Bad Version
Find 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 minAlgorithms - EASY
Move Zeroes
Move all zeroes to the end of an array in place while keeping the non-zero elements in their original order.
20 minAlgorithmsMeta · Google - EASY
Sum By / Mean By
Implement lodash sumBy and meanBy — total and average an array by an iteratee that maps each element to a number.
15 minJavaScript - MEDIUM
Array Product Excluding Current
Return an array where each entry is the product of every element except the one at that index, without division and in O(n).
25 minAlgorithmsAmazon · Meta · Microsoft - MEDIUM
Array.prototype.myReduce
PREMIUMImplement Array.prototype.myReduce — the reduce method from scratch, including the empty-array + initial-value edge cases.
20 minJavaScriptGoogle · Meta · Amazon - MEDIUM
Matrix Rotation
Rotate an n×n matrix 90 degrees clockwise and return the result as a new array.
25 minAlgorithmsAmazon · Microsoft · Apple - MEDIUM
Partition Equal Subset Sum
Decide whether an array can split into two subsets with equal sums — a subset-sum dynamic-programming problem over half the total.
25 minAlgorithms - MEDIUM
Pull / PullAll
Implement lodash pull and pullAll — remove every occurrence of the given values from an array in place, mutating the original.
30 minJavaScript - MEDIUM
Quickselect
PREMIUMFind the k-th smallest element of an unsorted array in average linear time by partitioning, without fully sorting it.
25 minAlgorithms - MEDIUM
Shuffle / Sample Size
Implement lodash shuffle and sampleSize with an unbiased Fisher-Yates swap, taking an injectable RNG so shuffles are testable.
30 minJavaScript - HARD
Median of Two Sorted Arrays
PREMIUMFind the median of two sorted arrays in logarithmic time by binary-searching for the partition that splits all the elements into equal halves.
40 minAlgorithms