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,076–3,100
Given an integer array and k sign-flip operations, maximize the array sum by choosing which elements to negate. The core challenge is a greedy selection…
General practice
Select up to k distinct numbers from nums to maximize their sum — equivalently, pick the largest unique values. Return those chosen values sorted in…
General practice
Companies: Amazon, Google
Array · Greedy · Matrix · Sorting
Given a weighted tree, remove edges so that each node's degree in the remaining forest is at most k while maximizing the total weight of…
Companies: LinkedIn, Uber
Depth-First Search · Dynamic Programming · Sorting · Tree
Given initial beauty values for garden patches and a limited budget of operations that can boost contiguous ranges, determine the maximum achievable garden "beauty" (e.g.…
General practice
Given a string of 'T'/'F' answers and at most k flips, maximize the length of a contiguous run of identical answers by changing up to…
General practice
Pick k given points that lie on a square's boundary to maximize the minimum pairwise Manhattan distance among the chosen points. The algorithmic challenge is…
General practice
Given an array points and up to m unit-step moves starting at index -1 where each visit to index i adds points[i] to gameScore[i], find…
General practice
Given an array of existing power stations where each station powers cities within radius r and k extra stations can be placed anywhere, maximize the…
General practice
Given a string s and integer k, you may change at most one character; then repeatedly remove the longest prefix that contains at most k…
General practice
Given two undirected trees, for each node i in the first tree find the maximum number of nodes (from both trees) that can be within…
General practice
Given two trees, for each node i in the first tree, choose one node in the second tree to connect with a single edge so…
General practice
Given weighted offers for contiguous ranges of houses, choose a set of non-overlapping offers to maximize total gold (some houses may remain unsold). This is…
General practice
Given an array where nums[0] is the top of a pile and in each move you may either pop the top or push back any…
General practice
Given per-tower upper bounds, assign each tower a unique positive integer height not exceeding its maximum to maximize the total sum (return -1 if impossible)…
General practice
Partition the array into contiguous subarrays to maximize the sum of each segment's alternating-signed sum (cost(l,r) = nums[l] - nums[l+1] + ...). The challenge is…
General practice
Select which fruits to buy given each fruit's price and tastiness to maximize total tastiness without exceeding a budget — a knapsack-style optimization. Expect to…
General practice
Given a functional directed graph defined by receiver (each node points to one node), choose a start index to maximize the sum of visited node…
General practice
Given sorted prize positions on a line, choose two integer segments of length k to maximize the number of distinct prizes covered (segments may overlap)…
General practice
Given paired arrays x and y, pick three indices with pairwise distinct x-values to maximize the sum of their y-values. This reduces to grouping y-values…
General practice
Given an integer made only of digits 6 and 9, maximize its value by flipping at most one digit (6↔9). Greedy insight: flip the most…
General practice
Find the contiguous subarray that maximizes the alternating sum formed by adding and subtracting consecutive elements (a[i] - a[i+1] + a[i+2] - ...). The core…
General practice
Choose a subsequence (order preserved) of nums to maximize its alternating sum — the sum of elements at even positions minus the sum at odd…
General practice