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,426–3,450
Given an array where you can perform up to k adjacent merges that replace two neighbors with their bitwise AND, find the minimum possible bitwise…
General practice
Given two equal-length arrays whose elements you may reorder, minimize the sum of element-wise products by choosing an optimal pairing between elements. The core insight…
General practice
Given a list of decimal numbers and an integer target, choose for each number whether to round down or up to an integer so that…
General practice
Given operations that delete the nearest equal character to the left or right of a chosen index, determine the smallest possible final length of the…
General practice
Pick one element from each row so the total sum is as close as possible to target; this is essentially a row-by-row reachable-sums/subset-sum (knapsack-like) problem…
General practice
Given an array where missing entries are marked -1, choose exactly two positive integers x and y (each missing element replaced by either x or…
General practice
Given an array nums and integer p, choose p disjoint index pairs to minimize the maximum absolute difference among the pairs. Typical solution pattern: sort…
General practice
Given a directed weighted graph, remove edges so every node has at most threshold outgoing edges and node 0 is reachable from all nodes, minimizing…
General practice
Find the smallest x such that from numbers 1..x you can choose disjoint sets of sizes uniqueCnt1 and uniqueCnt2 where the first set contains only…
General practice
Companies: Meta
Array · Greedy
Given a tree and many trips (each traversing any path between two nodes), you must minimize the total sum of node prices across all trips…
General practice
Given num1 and num2, find an integer x with the same number of set bits as num2 that minimizes num1 XOR x. This reduces to…
General practice
Given an array of positive numbers where you repeatedly replace any two elements with their product until a single value remains, determine the minimum possible…
General practice
Given an array nums and integer x, find the minimum |nums[i] - nums[j]| over all index pairs with |i - j| >= x. The core…
General practice
Companies: Snowflake
Array · Enumeration
For each k×k sliding submatrix of an m×n integer grid, compute the smallest absolute difference between any two distinct values; the core challenge is efficiently…
General practice
For each query asking about a subarray, compute the minimum absolute difference between any two distinct elements (return -1 if all elements are equal). The…
General practice
Companies: Amazon, Google, Meta, Microsoft
Array · Hash Table · Math
Given two equal-length arrays, you may replace at most one element in nums1 with any other element from nums1 to minimize the sum of |nums1[i]-nums2[i]|…
General practice
Find the smallest non‑negative x such that the digit sum of n+x is ≤ target. This reduces to finding the minimal increment that rounds n…
General practice
Given a string over {a,b,c}, compute the minimum number of insertions needed to turn it into a concatenation of "abc" blocks by aligning its characters…
General practice
Given a binary array and an integer k, find the minimum number of adjacent swaps needed to make k ones consecutive by choosing which k…
General practice
Given an array of distinct integers, find the minimum number of adjacent swaps to reorder it so parities alternate (even/odd/even/...), or return -1 if impossible…
General practice
Given an array and a validity condition for its arrangement (e.g., pairing/matching elements or grouping certain values), compute the minimum number of adjacent swaps needed…
General practice