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 1,401–1,425
Given two lists of apples and oranges with numeric weights, pair apples to oranges to maximize the number of pairs whose weight difference is ≤…
General practice
Determine whether you can transform binary string s into target by repeatedly picking indices i,j and replacing (s[i],s[j]) with (s[i] OR s[j], s[i] XOR s[j])…
General practice
Implement a Cashier class that maps product IDs to prices and returns the total bill (sum of amount[i] * price[product[i]]), applying a given percentage discount…
General practice
You're allowed to repeatedly pair elements and replace them with their bitwise AND and OR, which effectively transfers set bits between numbers; maximize the sum…
General practice
Sequentially scan the array and whenever adjacent elements are equal, double the left one and set the right one to zero (operations applied in order…
General practice
Given a lowercase string s, repeatedly perform rounds where you remove the first occurrence of each letter 'a' to 'z' (if present) until s becomes…
General practice
Starting from nums = [1], find the minimum number of operations (increment any element by 1 or duplicate any element) needed to make the array…
General practice
Given two binary strings, minimize the cost to make s1 equal to s2 using operations that flip any two bits at cost x or two…
General practice
Given an integer array and k unit increment/decrement operations, maximize the frequency of any value by changing elements; the core challenge is to find the…
General practice
Given nums and k, each operation picks an unused subarray and multiplies the score by the element in that subarray with the largest number of…
General practice
Companies: Google
Array · Breadth-First Search · Depth-First Search · Graph Theory
Return a new array where each element is the result of applying a provided mapping function to the corresponding input element and its index, i.e.…
General practice
Count the number of arithmetic subsequences (length ≥ 3) in an array — subsequences whose consecutive differences are all equal. The typical solution uses DP…
General practice
Given an array nums and m queries [l[i], r[i]], determine for each query whether the elements of the specified subarray can be rearranged to form…
General practice
Check whether a given non-negative integer is an Armstrong (narcissistic) number: compute the sum of its digits each raised to the power of the number…
General practice
Reorder the rows of a table so that entries are grouped by their gender attribute (e.g., all males before all females), typically while preserving the…
General practice
Find the largest k such that the triangular number 1+2+…+k ≤ n (i.e., k(k+1)/2 ≤ n); equivalently compute the maximum number of complete staircase rows…
General practice
Given a permutation nums of 0..n-1, repeatedly follow the mapping i -> nums[i] from each start index until a value repeats and form a set…
General practice
Determine whether the array's elements can be partitioned into pairs (x, 2x) for every element, i.e., each number must have a matching double; the core…
General practice
Given an array of 2n integers, partition the numbers into n pairs to maximize the sum of each pair's minimum value. This is an ordering/greedy…
General practice
Implement a polyfill for Array.prototype.forEach that iterates an array in order and invokes a provided callback for each present element with arguments (element, index, array)…
General practice
Add an Array.prototype.last() method that returns the last element of any array (arrays may contain any JSON values) and returns -1 when the array is…
General practice
Perform a sequential reduction (left fold) over nums by applying fn(accumulator, current) from left to right starting with init and return the final accumulator (return…
General practice
Companies: Snap
Given an integer array and a rule that updates each element simultaneously based on its neighbors or index, simulate that element-wise transformation for k steps…
General practice