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 2,376–2,400
Repeatedly pick the smallest unmarked element (ties by smallest index), add its value to the score, and mark that element and its immediate neighbors until…
General practice
Simulate assigning each request to server i%k or the next available server in circular order (drop if all busy), tracking completion times and counts per…
General practice
Given a weighted graph, find the minimum-cost path from a source to a destination using at most K hops (edges), which forces you to track…
General practice
Given an m×n matrix where each row is sorted in non-decreasing order, find the smallest integer that appears in every row (or return -1 if…
General practice
Given an integer matrix and a value K, count the submatrices whose entries are sorted non-decreasingly (by rows and columns) and whose maximum element is…
General practice
Check whether s contains a contiguous substring of exactly k identical characters such that the characters immediately before and after that block (if they exist)…
General practice
For each store with at least three distinct products, determine the most expensive and cheapest products and find stores where the most expensive product's quantity…
General practice
For each student and subject that have exams on at least two different dates, return the first and latest scores where the latest is higher…
General practice
Detect students whose time-ordered study sessions exhibit a repeating cycle of at least three distinct subjects that repeats for at least two full cycles (minimum…
General practice
Find a contiguous subarray whose bitwise OR is as close as possible to k (minimize |k - OR(nums[l..r])|). The challenge is to exploit that OR…
General practice
Determine whether any two distinct length-2 contiguous subarrays (adjacent pairs) in the array have the same sum — equivalently, check if any adjacent-pair sum appears…
General practice
Given an integer array nums and k, pick k elements (keeping their relative order) whose sum is maximized and return any such subsequence. The challenge…
General practice
Find the earliest length-k substring of s whose polynomial rolling hash (sum of val(ch)*power^i mod modulo) equals hashValue. This requires using modular arithmetic and an…
General practice
Given a rooted tree with a character on each node, simultaneously reparent every node (except the root) to its nearest ancestor that has the same…
General practice
Count the sum of products of all length-m sequences of indices (0..n-1) whose sum of 2^{index} has exactly k set bits; the challenge is to…
General practice
Return the indices that the target would occupy after sorting the array in non-decreasing order. This can be solved either by sorting and scanning or…
General practice
Repeatedly form the numeric concatenation of the first and last elements of an integer array (removing them) and sum these values, adding the lone middle…
General practice
Children in a line pass a ball one step per second, reversing direction whenever it reaches either end; determine which child holds the ball after…
General practice
Given a weighted undirected graph of n cities, compute for each city how many other cities are reachable within a given distanceThreshold via shortest paths…
General practice
Count how many n-digit integers (no leading zeros) have a digit multiset that can be rearranged into a palindrome divisible by k. The core challenge…
General practice
Count the number of pairs of non-negative integer arrays (arr1, arr2) of length n with arr1 non-decreasing, arr2 non-increasing, and arr1[i]+arr2[i]=nums[i] for all i —…
General practice
Count how many integers in [l, r] are not "special", where a "special" number has exactly two proper divisors — equivalently, it is a prime…
General practice