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,526–3,550
Given a string of 'a' and 'b', delete the fewest characters so that no 'b' appears before any 'a' (i.e., all remaining 'a's precede all…
General practice
Given a lowercase string and integer k, delete the fewest characters so that the frequencies of all remaining letters differ by at most k (i.e.…
General practice
Find the minimum number of nodes from the root to the nearest leaf in a binary tree (a leaf has no children), noting that nodes…
General practice
Given an array of student scores and an integer k, choose k scores so the difference between the highest and lowest selected score is minimized…
General practice
Given an integer array (n up to 1e5), you may change up to three elements to any value; return the minimum possible difference between the…
General practice
Partition the ordered list of jobs into d contiguous days (at least one job per day) to minimize the sum of daily difficulties, where each…
Companies: Atlassian, Microsoft
Array · Dynamic Programming
Given a sequence of daily arrivals, a window size w, and a per-type cap m, compute the minimum number of arrivals that must be discarded…
General practice
Given a BST root, return the minimum absolute difference between values of any two nodes; because an in-order traversal yields sorted values, the answer is…
General practice
Companies: Amazon, Google
Array · Hash Table
Companies: Amazon, Google, Microsoft
Array · Hash Table
Given an array, a target value, and a start index, return the minimum absolute distance |i - start| to any index i where nums[i] ==…
General practice
Find the minimum total Manhattan distance to type a given uppercase word on a fixed letter-coordinate keyboard using two fingers whose starting positions are free…
General practice
You can replace any composite number by its smallest prime factor (primes and 1 are unchanged) in one operation; find the minimum number of such…
General practice
Given two equal-length arrays representing the top and bottom numbers of dominoes, find the minimum number of single-domino rotations (swapping top and bottom) needed so…
General practice
Given a weighted tree and many independent queries, for each query compute the minimum number of edge weight changes needed to make all edges on…
General practice
Replace each number with the sum of its decimal digits and return the smallest resulting value. This is a simple linear scan computing digit-sums for…
General practice
Given nums, limit, and goal, find the minimum number of elements (each with absolute value ≤ limit) to add so the array sum equals goal…
General practice
Given two arrays where each 0 can be replaced by any positive integer, find the smallest possible equal sum you can make their totals both…
General practice
Given an integer target, find the smallest positive integer whose digits multiply to that target (return 0 if impossible). The challenge is to factor the…
General practice
Given an n×n integer matrix, find the minimum sum of any falling path that starts at any element in the first row and moves each…
General practice
Given an n×n matrix, pick one element from each row so that no two choices in adjacent rows share a column and return the minimum…
General practice