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 1,426–1,450
Given a sorted array (nondecreasing, may contain duplicates) and a target value, find the smallest index whose element is strictly greater than the target (the…
General practice
Rearrange a given array of distinct integers so that for every internal index i, nums[i] is not equal to the average of its neighbors —…
General practice
Implement an ArrayWrapper class that stores an integer array and supports operator overloading so that adding two instances returns the sum of all elements in…
General practice
Find all distinct authors who viewed their own articles by selecting rows where author_id = viewer_id (the Views table may contain duplicate rows), and return…
General practice
Given a log of article views (user_id, article_id, created_at), identify user–article pairs where the same user viewed the same article multiple times within a 7-day…
General practice
Given an n×n grid of 0s (water) and 1s (land), find the water cell whose Manhattan distance to the nearest land cell is maximal and…
General practice
Companies: Apple
Given arrays g (children's greed) and s (cookie sizes), assign at most one cookie per child so that s[j] >= g[i] and maximize the number…
General practice
For each group value, return the smallest-index element j such that elements[j] divides the group (groups[i] % elements[j] == 0), or -1 if none exists…
General practice
Given an 8x8 chessboard with one white rook, white bishops (blocks), and black pawns, determine how many pawns the rook can capture by moving straight…
General practice
Given an array of building heights and a set of contiguous segments (or a fixed window size), compute the average height for each segment; optimize…
General practice
Return an array where each element is the average of node values at that depth in a binary tree. This is a level-by-level aggregation problem…
General practice
Given employee records with department IDs and salaries, identify departments whose average salary is strictly greater than the company's overall average—requiring computation…
General practice
Given an array of unique salaries, compute the average salary after excluding the minimum and maximum values (i.e., average of the remaining n-2 elements). Array…
General practice
Match each sale to the correct price period (purchase_date within start_date–end_date) and compute the units-weighted average price per product as sum(price * units) /…
General practice
Given activity records with 'start' and 'end' timestamps for each (machine_id, process_id), compute for each machine the average processing time (end − start) across its…
General practice
Filter the array for numbers divisible by both 2 and 3 (i.e., divisible by 6) and return the floor of their average; if none exist…
General practice
Simulate a single-server FIFO queue: given sorted arrival and service times, process customers in order, advance the chef's clock through idle gaps, compute each customer's…
General practice
Assign dry operations on zero days so that no lake is rained on while already full: given a sequence where rains[i]>0 fills a lake and…
Companies: MongoDB
Array · Binary Search · Greedy · Hash Table
Given a BST, produce any height-balanced BST containing the same node values (a tree where the depths of left and right subtrees of every node…
General practice
Check whether a binary tree is height-balanced, i.e., for every node the heights of its left and right subtrees differ by at most one. With…
Companies: Anduril
Binary Tree · Depth-First Search · Tree
Split n into exactly k positive integers whose product equals n while minimizing the difference between the largest and smallest part. The core challenge is…
General practice
Given a list of bank transactions (account id, amount, timestamp/type), produce per-account summaries such as current balance, total deposits/withdrawals, or balances at…
General practice
Compute each user's balance by summing their transaction amounts (transactions may be positive or negative, and all accounts start at 0), then report the name…
General practice
Convert the given integer to its base-7 string representation, preserving a leading '-' for negative numbers and returning "0" for zero.
General practice