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,626–1,650
Given an undirected weighted graph, determine for each query whether there exists a path between two nodes using only edges with weights strictly less than…
General practice
Design a data structure to handle a sequence of operations that add weighted edges and answer whether two nodes are connected by a path whose…
General practice
Given an n×n grid with cherries (1), empty cells (0) and thorns (-1), find the maximum cherries collectible by going from (0,0) to (n-1,n-1) moving…
General practice
Given a tree and an integer k, pick k edges whose removal (or selection) maximizes a score defined by each edge's contribution based on the…
General practice
For each index i, compute the maximum sum obtainable by picking up to k values from nums2 at indices j where nums1[j] < nums1[i]. The…
General practice
Given two integer arrays and a numeric interval/width constraint, pick elements from either array so that the resulting selection's values all lie within that range…
General practice
Partition the input array into consecutive subarrays (chunks) of the given size, with the final chunk possibly shorter if the array length isn't a multiple…
General practice
Determine whether an axis-aligned rectangle and a circle overlap (i.e., share any point) — a geometry problem that reduces to computing the rectangle point closest…
General practice
Generate any cyclic n-bit Gray-code ordering of all numbers 0..2^n-1 that starts with start, i.e., a permutation where each adjacent pair (including last→first) differs by…
General practice
Check whether a sentence is "circular" by verifying that each word's last character equals the next word's first character (including the last word back to…
General practice
Given student records with class identifiers and scores, compute per-class performance metrics (e.g., average of top-K scores, pass-rate, or relative rankings) and answer any…
General practice
Given a table of student-class enrollments, return the names of classes that have at least five students by grouping rows by class and filtering groups…
General practice
Companies: Citadel
Given three integers as side lengths, determine whether they form a valid triangle (positive lengths satisfying the triangle inequality) and classify it as "Equilateral"…
General practice
Given a string of lowercase letters and digits, repeatedly remove each digit together with the nearest non-digit to its left until no digits remain, and…
General practice
Count the number of distinct sequences of 1- or 2-step moves that sum to n — the ways follow the recurrence ways(n)=ways(n-1)+ways(n-2) (i.e., Fibonacci-like), with…
Companies: Bloomberg, Google, Intuit, Meta +1
Dynamic Programming · Math · Memoization
Given the root of an N-ary tree, produce a deep copy that recreates every node and its list of children while preserving the original tree…
General practice
Pick exactly one base and 0–2 of each topping to form a total cost as close as possible to a given target (ties favor the…
General practice
Given num, find two integers whose product equals either num+1 or num+2 and whose absolute difference is minimal, and return that factor pair. The typical…
General practice
Given a circular array and multiple queries, for each query return the minimum circular distance from the queried index to any other index with the…
General practice
Given an integer N, find the nearest integer (by absolute difference, with usual tie-breaking) whose decimal representation has every digit occurring an even number of…
General practice
Given a binary tree and a target node value, return the value of the nearest leaf measured by edge distance — you may move both…
General practice
Given a tree and many queries specifying a path between two nodes, for each query return which candidate node (from a given set) is closest…
General practice