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 4,576–4,600
Compute the total sum of all odd-length contiguous subarrays of a given array — equivalently, sum each element weighted by how many odd-length subarrays include…
General practice
Compute the sum of bitwise XORs of every subset of nums; observe each bit that appears in any element contributes independently and shows up in…
General practice
Compute the sum over all positive g of g times the number of strictly increasing subsequences of nums whose GCD equals g (mod 1e9+7). The…
General practice
For each interior element, determine whether it's greater than all previous elements and smaller than all following elements (beauty 2), else whether it is strictly…
General practice
Compute the sum, over all substrings of s (n ≤ 500), of the "beauty" defined as the difference between the most frequent and least frequent…
General practice
Given an integer array, identify and count contiguous subsequences whose summed value meets a specified criterion (e.g., equals a target or lies in a given…
General practice
Given an array of equal-length positive integers, return the total number of digit positions that differ across all unordered pairs of numbers. The core challenge…
General practice
Convert n from base 10 to base k and return the sum of its digits (each digit interpreted as a base-10 integer). This tests basic…
General practice
Given an array of integers, find the minimum element and return the sum of its decimal digits. This requires scanning to get the minimum (O(n))…
General practice
Convert the string by replacing each letter with its alphabet index concatenated into a decimal number, then repeatedly replace the number with the sum of…
General practice
For each index, compute the sum of absolute differences between its index and all other indices with the same value; if no duplicates exist, the…
General practice
Given a tree with n (≤ 3·10^4) nodes, compute for every node the sum of distances to all other nodes. This requires an O(n) tree-DP…
General practice
Given nums and queries where each query adds a value to nums[index], return the sum of even numbers after each update. The challenge is to…
General practice
Compute the sum of floor(nums[i] / nums[j]) over all index pairs (mod 10^9+7). The challenge is to avoid O(n^2) by using value frequency/count arrays and…
General practice
Companies: Amazon, Bloomberg, Google, Microsoft
Array · Math · Number Theory · Simulation
Given an array nums and integer k, return the sum of all elements nums[i] that are strictly greater than the elements at indices i-k and…
General practice
Compute the total sum of elements over all subsequences of nums that are "good" (every pair of consecutive elements in the subsequence has absolute difference…
General practice
Compute the sum, over all contiguous subarrays, of the number of “gaps” in the sorted subarray where consecutive sorted values differ by more than 1…
General practice
Pick k non-overlapping subarrays from nums, each of length at least m, to maximize the total sum. The core challenge is selecting optimal interval placements…
General practice