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,576–1,600
Determine whether a binary string s contains every possible binary substring of length k (i.e., all 2^k distinct codes). With k ≤ 20 and |s|…
General practice
Given a binary tree and an integer array, determine whether there exists a root-to-leaf path whose node values in order exactly match the array. This…
General practice
Determine whether s equals the string formed by concatenating the first character of each word in words (i.e., check that s[i] == words[i][0] for every…
General practice
Given a space-separated sentence and a searchWord, determine whether searchWord is a prefix of any word and return the 1-based index of the first matching…
General practice
Check whether every 1 in a binary array is separated from the next 1 by at least k positions—i.e., ensure there are at least k…
General practice
Given a string of only 'a' and 'b', determine whether all 'a' characters occur before any 'b' characters — equivalently, ensure there is no 'a'…
General practice
Determine whether every character that appears in the given lowercase string occurs the same number of times by computing character frequencies and checking that all…
General practice
Given a list of inclusive integer intervals, determine whether the union of those intervals covers every integer in the target range [left, right]. Due to…
General practice
Check whether an unsorted array's elements form a sequence of consecutive integers with no gaps or duplicates. Typically this reduces to verifying that max−min+1 equals…
General practice
Determine whether two strings of letters and digit-substrings (where digits represent lengths of omitted substrings) can both be encodings of the same original string. The…
General practice
Count element frequencies in the array and return true if any frequency is a prime number (>1). This reduces to frequency counting (map/array) and checking…
General practice
Determine whether nums is a permutation of base[n] = [1,2,...,n,n] where n is the array's maximum. Equivalently, check that len(nums) == n+1 and numbers 1..n-1…
General practice
Determine whether the array can be obtained by rotating a non-decreasing (non-decreasing allows duplicates) array — equivalently, check that there is at most one index…
General practice
Determine whether the array can be paired so every pair sums to a multiple of k by looking at element remainders mod k: you must…
General practice
Check whether a binary string (guaranteed to start with '1') contains at most one contiguous run of '1's — equivalently, verify that the pattern '1...0...1'…
General practice
Check whether there exists a subset of two or more elements whose bitwise OR is even (has at least one trailing zero); this reduces to…
General practice
Given a rooted tree with a character on each node, for every node i form the post-order DFS string obtained by recursively visiting its children…
General practice
Repeatedly replace the string with the sequence of sums (mod 10) of each adjacent digit until only two digits remain, and return whether those final…
General practice
Given a digit string s, repeatedly replace it by the sequence of pairwise sums modulo 10 of adjacent digits until only two digits remain, and…
General practice
Determine whether every row and every column of an n×n matrix contains all integers from 1 to n (i.e., each row/column is a permutation of…
General practice
Determine whether all non-overlapping rectangles can be separated into three non-empty contiguous vertical or horizontal strips by placing two parallel cut lines so that no…
General practice
Check whether every cell in an m×n grid equals the cell below it (when present) and differs from the cell to its right (when present)…
General practice
Check whether some integer linear combination of the array elements can equal 1 — equivalently determine if the greatest common divisor of all numbers in…
General practice
Determine whether all given 2D points are collinear — i.e., lie on a single straight line in the plane by checking that slopes between points…
General practice
Determine whether you can recursively split the array into contiguous segments until all are singletons, where each split is allowed only if both resulting parts…
General practice