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 3,451–3,475
Find the k-th lexicographically next permutation of the digit string (the k-th smallest greater permutation) and return the minimum number of adjacent digit swaps needed…
General practice
Each enemy requires ceil(health[i]/power) hits and deals damage[i] per second while alive, so total damage equals the weighted sum of completion times. The problem reduces…
General practice
Three trucks (for M, P, G) start at house 0 and must visit houses in order to pick up one-minute-per-unit garbage with given travel times…
General practice
Given three nonnegative cup counts and the rule that each second you may fill either two cups of different types or one cup of any…
General practice
Given an even-length array and allowed values 0..k, find the minimum number of element replacements so that every mirrored pair satisfies |a[i] - a[n-1-i]| =…
General practice
Given n and x, construct a strictly increasing array of n positive integers whose bitwise AND equals x and return the smallest possible value of…
General practice
Given a sorted array, repeatedly remove any pair of elements (i, j) with nums[i] < nums[j]; return the minimum possible length after performing removals. This…
General practice
Given nums and limits op1/op2, you may apply at most op1 operations that replace nums[i] with ceil(nums[i]/2) and at most op2 operations that subtract k…
General practice
Find the minimum total ASCII value of characters that must be deleted from two strings to make them equal; this is equivalent to picking a…
General practice
Compute, for each index i, the absolute difference between the floor average of the first i+1 elements and the floor average of the remaining elements…
General practice
Given an even-length integer array, repeatedly pair the smallest and largest elements, compute their averages, and return the smallest such average — equivalently, sort the…
General practice
Count the number of differing bit positions between start and goal — equivalently, return the number of 1s in start XOR goal, which is the…
General practice
Companies: Google
Array · Bit Manipulation · Greedy · Matrix
Given a binary string, determine the minimum number of bit flips needed to make it alternating (no equal adjacent chars) by comparing it against the…
General practice
Partition the string s into k contiguous substrings to minimize the total number of character changes, where the cost of a substring is the minimum…
General practice
Given two non-decreasing integer arrays, return the smallest integer that appears in both arrays (or -1 if no common element exists). Because the arrays are…
General practice
Find the minimum length of a contiguous subarray that contains at least two equal values (a matching pair of cards); return -1 if no duplicates…
General practice
Given costs for each horizontal and vertical cut on an m×n cake where each cut's cost is incurred once for every segment it crosses, determine…
General practice
Given costs for each horizontal and vertical cut needed to split an m×n cake into 1×1 pieces, determine the cut order that minimizes total cost…
General practice
Given sorted travel days and prices for 1-, 7-, and 30-day passes, choose which passes to buy to cover every travel day at minimum total…
General practice
Given a string where each character can be shifted left/right in the alphabet at unit cost, compute the minimum total shifts to make every letter…
General practice
Compute the minimum cost to move a robot from start to home on an m×n grid where entering row r costs rowCosts[r] and entering column…
General practice