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,301–2,325
Given a binary tree where every node value is contaminated as -1 but the original labels follow root = 0 and for node x, left…
General practice
Given a directed graph, return all "eventual safe" nodes — nodes from which every possible path ends at a terminal node — which is equivalent…
General practice
Given city prices (and optionally connections), identify which cities are "expensive" — e.g., whose price exceeds a given threshold or is strictly greater than all…
General practice
Return the first string in the given array that reads the same forward and backward (a palindrome), or return an empty string if no such…
General practice
Given a Followers table of (user_id, follower_id) pairs, compute the number of followers for each user by grouping and counting follower_id per user, and return…
General practice
Find all indices i (with at least time elements on each side) such that the preceding time elements form a non-increasing sequence and the following…
General practice
Return the greatest common divisor of the smallest and largest numbers in the array — the task reduces to finding min and max and computing…
General practice
Determine whether an array can be sorted using only adjacent swaps between numbers that have the same number of set bits. The key challenge is…
General practice
Given an array of positive integers (1–99), Alice must take either all single-digit numbers or all double-digit numbers and Bob gets the rest; determine whether…
General practice
Given a mountain (strictly increasing then strictly decreasing) array accessible only via a limited-call MountainArray interface, return the smallest index where the value…
General practice
Given an array height and an integer threshold, return all indices i > 0 such that the previous mountain's height (height[i-1]) is strictly greater than…
General practice
Find any pair of indices i, j such that abs(i - j) >= indexDifference and abs(nums[i] - nums[j]) >= valueDifference, returning [i, j] if found…
General practice
Given an integer array and thresholds k (indexDifference) and t (valueDifference), find any pair of indices i, j with |i−j| ≥ k and |nums[i]−nums[j]| ≥…
General practice
Given candidate records and a set of selection rules (e.g., score/experience thresholds, availability, and limited interview slots), identify which candidates should be invited…
General practice
Write an SQL query that parses and validates IPv4 strings in the logs (invalid if any octet >255, any octet has leading zeros, or there…
General practice
Given a string s and integer k, return all (distinct) length-k substrings that contain no repeated characters. This is solved by a sliding-window with a…
General practice
Given an array nums, return the k-th smallest absolute difference among all pairs nums[i], nums[j] (i < j). Typical efficient approach (needed for n up…
General practice
Given S1 = "0" and Si = S{i-1} + "1" + reverse(invert(S{i-1})), return the k-th bit of S_n. Use the string's length (2^n−1) and its…
General practice
Given an m×n matrix, compute for each coordinate (a,b) the XOR of all elements in the submatrix from (0,0) to (a,b) (2D prefix XORs) and…
General practice
Given the root of a binary tree, return an array of the maximum value in each level (row) of the tree from top to bottom…
General practice
Given a permutation arr that flips positions from 0 to 1 over n steps, determine the last step index at which there exists a contiguous…
General practice
Given employee salary history with multiple records per person, return each employee's most recent salary by selecting the record with the latest effective date (commonly…
General practice