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,176–3,200
Find the length of the longest substring in which every character appears at most twice. This is a sliding-window/counting problem over a small lowercase alphabet…
General practice
Compute the sum of node values at each depth of a binary tree and return the smallest level index with the maximum sum. This is…
General practice
Given an array of stock prices, find two indices i < j that maximize a score defined by a linear combination of prices and their…
General practice
Given a sequence of unit grid moves where you can change up to k moves to any direction, compute the maximum Manhattan distance from the…
General practice
Given arrays of player abilities and trainer capacities, pair each player to at most one trainer (and vice versa) so that a player’s ability ≤…
General practice
Given an n×n integer matrix where you may multiply any two adjacent (edge-sharing) elements by -1 any number of times, maximize the matrix sum. Because…
General practice
Partition the array into n/3 triplets and maximize the sum of their medians; the key insight is that after sorting you can greedily choose the…
General practice
Given four fixed weights a[0..3] and an array b, pick indices i0<i1<i2<i3 to maximize the weighted sum a[0]*b[i0]+a[1]*b[i1]+a[2]*b[i2]+a[3]*b[i3]; the core challenge is…
General practice
Given a valid parentheses string, assign each character to one of two disjoint valid-parentheses subsequences A and B (output 0/1 per index) so that the…
Companies: Microsoft
Bracket Sequences · Stack · String
Find a right/down path from the top-left to bottom-right that maximizes the product of visited cells, returning the maximum non-negative product modulo 1e9+7 (or -1…
General practice
Given an n×n boolean matrix where matrix[i][j] indicates whether person i would accept an invitation from person j, compute the largest number of accepted invitations…
General practice
Given directed transfer requests between n buildings, find the largest subset of requests such that each building's net incoming minus outgoing transfers is zero (so…
General practice
Given k possible recipes (machines), each with per-unit metal requirements across n metal types, limited initial stock, and per-unit purchase costs, determine the maximum…
General practice
Count the frequency of letters in the input string and determine how many times you can assemble the word "balloon" (using each character once), noting…
General practice
Count how many numbers in the range [lowLimit, highLimit] map to each box indexed by the sum of their digits, and return the largest frequency…
General practice
Given an array of piles where each element is the number of books on a shelf, pick a contiguous segment and take books from right…
General practice
Given 3n piles, you repeatedly pick any three piles where Alice takes the largest, you take the second-largest, and Bob takes the smallest; compute the…
General practice
Given an array of coin values, find the largest count of consecutive integers starting from 0 that can be formed as subset sums. This is…
General practice
Given nums and k, you may shift each element by any integer in [-k,k] at most once; maximize the number of distinct final values. This…
General practice
Given daily apple yields each with a spoil-after duration and the ability to eat at most one apple per day (even after day n), maximize…
General practice
Given a list of weighted intervals and an integer k, pick at most k non-overlapping events (end days are inclusive) to maximize the total value…
General practice
Given an m×n grid where positive cells contain fish and zeros are land, find the maximum total fish a fisher can collect by starting at…
General practice
Partition the multiset of student grades into the maximum number of ordered non-empty groups (reordering allowed) such that both the group sizes and the sums…
General practice