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,251–2,275
Given a list of user activity records (userId, timestamp), identify users who meet the "active" criterion (e.g., at least k actions within a recent time…
General practice
Given an array of length n with values in [1,n] where each value appears once or twice, return all values that appear twice in O(n)…
General practice
Find indices i (k <= i < n-k) such that the k elements before i form a non-increasing sequence and the k elements after i…
General practice
Count the number of length-n lowercase strings lexicographically between s1 and s2 (inclusive) that do not contain the substring evil, returning the result mod 1e9+7…
General practice
Given an m x n binary matrix containing disjoint, axis-aligned rectangular blocks of 1s, return for each block the coordinates [r1,c1,r2,c2] of its top-left and…
General practice
Return all indices i such that there exists an index j with nums[j] == key and |i - j| <= k — equivalently, compute the…
General practice
Find all integers that occur exactly once in nums and whose immediate neighbors (x-1 and x+1) do not appear in the array; return these "lonely"…
Companies: Apple
Array · Counting · Hash Table
Companies: TCS
Array · Binary Search · Sorting
Given timestamped pairwise meetings and that person 0 initially shares a secret with firstPerson at time 0, determine who knows the secret after all meetings…
General practice
Count how many binary arrays of length zero+one contain exactly zero zeros and one ones and have no run of identical bits longer than limit…
General practice
Count the number of binary arrays with exactly zero zeros and one ones such that no run of identical bits exceeds length limit (equivalently, every…
General practice
Given a binary tree, return the values of all "lonely" nodes — nodes whose parent has exactly one child (i.e., they have no sibling). This…
General practice
Given a list of email addresses, extract the domain part (the substring after '@') from each address and return all unique domains; this is essentially…
General practice
Given two arrays A and B where B is a permutation (an anagram) of A, return an index array P such that for each i…
General practice
Given a string s and parallel arrays indices, sources, and targets, perform all replacements simultaneously: for each i, if sources[i] matches s starting at indices[i]…
General practice
Return the words that are isomorphic to a given pattern: for each word, check whether there exists a bijective mapping from letters in the pattern…
General practice
Given the multiset of all 2^n subset sums, reconstruct any original length-n integer array. The core challenge is to infer each element by partitioning the…
General practice
Find all start indices i where substring a occurs in s and there exists a start j where substring b occurs such that |i -…
General practice
Find all start indices i where substring a occurs in s and there exists a start j where substring b occurs with |j − i|…
General practice
Identify books for which the number of currently borrowed copies (COUNT of borrowing_records with NULL return_date) equals total_copies, meaning zero copies are available…
General practice
Identify books by joining books with reading_sessions and grouping by book to compute highest and lowest ratings (rating spread), total sessions, and count of extreme…
General practice
Return the leftmost value in the last row of a binary tree — i.e., find the first node in the deepest level. This is a…
General practice
For each query (a,b) return the leftmost index j > max(a,b) such that heights[j] > heights[a] and heights[j] > heights[b], or -1 if no such…
General practice
Given a stream of timestamped events, identify time intervals where activity spikes sharply compared to the surrounding baseline — typically solved by sliding-window or…
General practice