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,501–4,525
Split a string into the minimal number of parts such that each part appended with a suffix " " (whose length varies with the digit…
General practice
Given an array of strings and a separator character, split each string by that separator (excluding the separator) and return a flattened array of non-empty…
General practice
Given an even-length array, determine whether you can split it into two equal-sized halves such that each half contains only distinct elements — equivalently, check…
General practice
Find the smallest index i where the product of nums[0..i] and nums[i+1..n-1] are coprime — equivalently, where no prime factor appears on both sides. With…
General practice
Given two equal-length strings a and b, determine whether there exists a split index such that a_prefix + b_suffix or b_prefix + a_suffix is a…
General practice
Partition the multiset of digits of a given positive integer into two nonnegative integers (reordering and leading zeros allowed) such that all digits are used…
General practice
Check if a digit string can be partitioned into two or more contiguous substrings whose integer values (leading zeros allowed) form a strictly descending consecutive…
General practice
Compute the integer square root: for a non-negative integer x (0 ≤ x ≤ 2^31-1), return floor(sqrt(x)) without using built-in exponent functions — typically solved…
Companies: Google
Binary Search · Math · Newton's Method
Given a grid with one squirrel, one tree, and multiple nuts where the squirrel can carry one nut at a time and movement cost is…
General practice
Companies: Amazon, Microsoft
Array · Hash Table · Prefix Sum
Given an m x n binary grid and an unrotatable stamp of size h x w, determine whether you can place stamps (any number, stamps…
General practice
Given a stamp and a target, find a sequence of left indices where placing the stamp on an all-'?' string yields target within 10*n moves…
General practice
Given a frequency array count[0..255] representing a large multiset, compute the minimum and maximum as the first/last indices with nonzero counts, the mean as the…
General practice
Given N flight tickets and a sequence of operations that set or change the status of contiguous ticket ranges and ask for status information (e.g.…
General practice
Given a binary tree with unique node values, produce the shortest path from start node s to destination t as a string of 'L', 'R'…
Companies: Snowflake
Binary Lifting · Binary Tree · Depth-First Search · Lowest Common Ancestor
Find all integers in a given inclusive range whose adjacent digits differ by exactly 1 (stepping numbers), including single-digit and zero cases. Because the range…
Companies: eBay
Backtracking · Breadth-First Search · Math
Given an array where, in each round, you simultaneously remove every element that is strictly less than its left neighbor, compute how many rounds are…
General practice
Given sticker words (each supplying a multiset of letters, available in unlimited quantity), find the minimum number of stickers whose combined letters can be cut…
General practice
Two-player game: from the start of the remaining piles a player may take X piles with 1 ≤ X ≤ 2M (then M = max(M…
General practice
Two players alternately take 1–3 stones from the front of an array of integers (which may be negative), each accumulating the values they take. Determine…
General practice
Two players alternately remove any positive perfect-square number of stones from a pile of n, and the player who cannot move loses; determine whether Alice…
General practice
Two-player turn-based removal game where the player who makes the running sum of removed stone values divisible by 3 loses; determine whether Alice can force…
General practice
Given an array of stone values, Alice repeatedly splits the current subarray into two non-empty parts; Bob discards the part with the larger sum (if…
General practice
Two players alternately pick stones (Alice first) from n items where stone i gives aliceValues[i] to Alice and bobValues[i] to Bob; under optimal play, determine…
General practice