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 4,476–4,500
Given nums up to 1e5 elements with values ≤ 5e4, compute how many pairs have each possible gcd value by counting numbers divisible by d…
General practice
Given a shuffled sentence where each word has its 1-indexed position (a digit 1–9) appended, reconstruct the original sentence by ordering words by that position…
General practice
Given an array of values in {1,2,3}, remove the fewest elements so the remaining sequence is non-decreasing. This is equivalent to maximizing the length of…
General practice
Compute the probability that soup A is emptied before B (counting ties as half) under a random process of four equal-probability pours that reduce A…
General practice
Check whether every adjacent pair in the integer array has opposite parity (one even, one odd). Return true if all neighboring elements alternate in parity…
General practice
For each query, determine whether the subarray's adjacent elements strictly alternate parity (no two consecutive numbers share the same parity). With up to 1e5 elements…
General practice
Determine whether there exists an integer x (0 ≤ x ≤ n) such that exactly x elements in nums are ≥ x; return that unique…
General practice
Given a special binary string (balanced and every prefix has at least as many 1s as 0s), the task is to repeatedly swap adjacent special…
General practice
Count the number of permutations of distinct positive integers where every adjacent pair satisfies that one divides the other, returning the result modulo 10^9+7. With…
General practice
Count the positions (i, j) in an m x n binary matrix that contain a 1 and are the only 1 in both their row…
General practice
Generate an n×n matrix containing the integers 1..n^2 arranged in clockwise spiral order, starting at the top-left and proceeding along the top row, right column…
General practice
Starting from (rStart,cStart), generate an outward clockwise spiral path (you may step outside the grid) and return the coordinates that lie inside the rows×cols bounds…
General practice
Given a balanced string of 'L' and 'R', partition it into the maximum number of contiguous substrings each having an equal number of L and…
General practice
Given a string s (length ≤ 16), partition it into contiguous non-empty substrings whose concatenation equals s so that all substrings are distinct, and return…
General practice
Given two length-n arrays where nums2 is a permutation of nums1, find the minimum number of operations that cut out any contiguous subarray from nums1…
General practice
Partition the array into two sums based on whether an element's 0-based index is a prime number, and return the absolute difference |sum(prime-index elements) -…
General practice
Given a sorted integer array, determine whether you can partition its elements into one or more disjoint subsequences that are strictly consecutive (difference 1) and…
General practice
Given a string of digits, split it into at least three numbers that form a Fibonacci-like sequence (each number equals the sum of the previous…
General practice
Partition the array into contiguous subarrays so that the sum of each subarray's bitwise AND is as small as possible, and among all such optimal…
General practice
Determine whether you can choose three split indices to partition an integer array into four non-overlapping subarrays that all have the same sum. The core…
General practice
Determine if nums can be split into two non-empty subsets with the same average — equivalently, check whether there exists a subset of size k…
General practice
Given a string formed by concatenating some words from a given list, determine whether (and how) it can be split back into those original words…
General practice