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
- JavaScriptCoding exercise
Array XOR (Symmetric Difference)
EASYImplement lodash xor — return the values that appear in exactly one of the given arrays, with duplicates removed.
20 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 - 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 - JavaScriptCoding exercise
Sum By / Mean By
EASYImplement lodash sumBy and meanBy — total and average an array by an iteratee that maps each element to a number.
15 minPractice - AlgorithmsCoding exercise
Array Product Excluding Current
MEDIUMReturn an array where each entry is the product of every element except the one at that index, without division and in O(n).
25 minAmazon · Apple · Meta +1Practice - JavaScriptCoding exercise
Array.prototype.myReduce
MEDIUMImplement Array.prototype.myReduce — the reduce method from scratch, including the empty-array + initial-value edge cases.
20 minAmazon · Google · Meta +1Practice - AlgorithmsCoding exercise
Matrix Rotation
MEDIUMRotate an n×n matrix 90 degrees clockwise and return the result as a new array.
25 minAmazon · Apple · MicrosoftPractice - 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 - JavaScriptCoding exercise
Pull / PullAll
MEDIUMImplement lodash pull and pullAll — remove every occurrence of the given values from an array in place, mutating the original.
30 minPremium questionPractice - 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
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
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