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,301–3,325
Select exactly k ordered, non-overlapping subarrays to maximize a weighted sum where the i-th chosen subarray contributes (k-(i-1)) times its sum with alternating signs (k*sum1…
General practice
Given an m x n matrix, find the maximum number of cells you can visit by starting at any cell and repeatedly jumping to any…
General practice
Find the maximum bitwise XOR of any two elements (you may pick the same element twice) from nums such that they form a strong pair…
General practice
Find the maximum bitwise XOR of two elements (you may pick the same element twice) from nums under the "strong pair" constraint |x−y| ≤ min(x,y)…
General practice
Given a bench represented by a row of seats (some usable, some blocked), determine the maximum number of students that can be placed on that…
General practice
Place the maximum number of students on usable seats in an m×n grid so that no two are adjacent horizontally or diagonally between consecutive rows…
General practice
Find the maximum value of (minimum element of a contiguous subarray) × (sum of that subarray) over all non-empty subarrays and return it mod 1e9+7…
General practice
Companies: Google
Array · Binary Indexed Tree · Greedy · Hash Table
Companies: Amazon, Google
Array · Dynamic Programming
Given an integer array, you may apply a single operation to one contiguous subarray (e.g., doubling every element in that segment); compute the maximum subarray…
General practice
Find the maximum sum of any contiguous subarray whose length is a multiple of k; this reduces to using prefix sums and pairing indices with…
General practice
Find the maximum sum of a non-empty contiguous subarray when you may remove at most one element; this is solved by a Kadane-style DP that…
General practice
Find the length of the longest contiguous subarray whose product equals gcd times lcm of its elements. With n ≤ 100 and values ≤ 10…
General practice
Companies: Microsoft
Array · Depth-First Search · Dynamic Programming · Tree
Given a rooted tree where each node has a color, find the size of the largest subtree (a node plus all its descendants) in which…
General practice
Given a binary tree, find the maximum sum of node values among all subtrees that are valid Binary Search Trees (a subtree is any node…
General practice
Given a circular integer array, return the maximum sum of any non-empty contiguous subarray (allowed to wrap from end to start). Typical solution uses Kadane’s…
General practice
Given a binary tree, find the maximum sum path from any leaf node to the root. Example: Input: A binary tree where 10 is the…
General practice
Given nums and many inclusive range requests, permute nums to maximize the total sum of all requested subarray sums; the core idea is to compute…
General practice
Find the maximum sum of any contiguous subarray of length k that contains at least m distinct elements (return 0 if none). This is a…
General practice
Companies: Visa
Array · Dynamic Programming · Segment Tree
Find the maximum sum of any fixed 7-cell "hourglass" shape (three cells in a top row, the middle cell of the next row, and three…
General practice