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 26–46
Count the number of length-goal sequences using n distinct songs such that every song appears at least once and a song can be replayed only…
Companies: Google, ServiceNow
Combinatorics · Dynamic Programming · Math
Last reported Jul 2024
Add two binary strings and return their sum as a binary string by performing digit-wise addition from the least significant bit with carry, handling unequal…
Companies: Meta
Bit Manipulation · Math · Simulation · String
Return the sum of two given integers num1 and num2 (they may be negative); simply compute and return num1 + num2 (constraints: -100 to 100).
Companies: Google
Math
Place n unit cubes into stacks on an n×n floor with the rule that a cube can be stacked only if the supporting cube's four…
Companies: Adobe
Binary Search · Greedy · Math
Given n bulbs toggled on each i-th round for multiples of i, determine how many bulbs remain on after n rounds — this reduces to…
Companies: LinkedIn
Brainteaser · Math
Count the number of distinct sequences of 1- or 2-step moves that sum to n — the ways follow the recurrence ways(n)=ways(n-1)+ways(n-2) (i.e., Fibonacci-like), with…
Companies: Bloomberg, Google, Intuit, Meta +1
Dynamic Programming · Math · Memoization
Count the number of contiguous subarrays that contain exactly k odd numbers in an integer array. The core challenge is to do this in linear…
Companies: TikTok
Array · Hash Table · Math · Prefix Sum
Given a total amount and number of children, allocate all money so each child gets at least $1 and nobody gets $4, and return the…
Companies: MongoDB
Greedy · Math
Given n people seated in a circle, repeatedly remove every k-th person clockwise until one remains and return their label — the classic Josephus problem…
Companies: Goldman Sachs
Array · Math · Queue · Recursion
Given a binary sequence that evolves each row by replacing 0→01 and 1→10 (so row lengths double each time), return the k-th symbol in the…
Companies: D. E. Shaw
Bit Manipulation · Math · Recursion
Convert each point to its polar angle around your location (counting points at the exact location separately), sort these angles and handle the circular wrap…
Companies: Anduril
Array · Geometry · Math · Sliding Window
Companies: Atlassian
Array · Combinatorics · Enumeration · Hash Table
Given a nonnegative integer, perform at most one swap of two digits to obtain the largest possible number. This is solved greedily by identifying the…
Companies: Apple
Greedy · Math
Given an integer array where you may replace any element with two positive integers summing to it, find the minimum number of such split operations…
Companies: Salesforce
Array · Greedy · Math
Given a set of 2D integer points and multiple circular queries, compute for each circle how many points lie inside or on it; the main…
Companies: Anduril
Array · Geometry · Math
Convert a valid Roman numeral string into its integer value by applying the additive and subtractive rules (e.g., IV = 4, IX = 9, CM…
Companies: Google, Microsoft
Hash Table · Math · String
Given inventories where each sale of a color yields value equal to its current count and reduces that count by one, choose which balls to…
Companies: Goldman Sachs
Array · Binary Search · Greedy · Heap (Priority Queue)
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
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 of nonnegative integers, compute the sum of Hamming distances over all pairs of numbers. Key idea: for each bit position, count how…
Companies: Apple
Array · Bit Manipulation · Math
Given four unordered 2D points, determine whether they form a valid square (four equal non-zero side lengths and four right angles). A common check is…
Companies: Pure Storage
Geometry · Math