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 3,876–3,900
Given a positive integer, return the integer formed by flipping every bit in its binary representation up to its most significant 1 (i.e., invert all…
General practice
Given Accounts and Streaming records, return how many accounts have no streaming activity in the specified period — solved by using an anti-join (NOT EXISTS…
General practice
Given an array of length n initially filled with 0 (uncolored), process point updates that set an index to a color and after each update…
General practice
Count how many integers in [low, high] have an equal number of even and odd digits and are divisible by k. This is typically solved…
General practice
Count the number of index pairs i < j such that the first digit of nums[i] and the last digit of nums[j] are coprime (gcd…
General practice
Count the number of ways to split string s into k contiguous substrings (each length ≥ minLength) such that every substring starts with a prime…
General practice
Check whether every 1-bit in k is also 1 in n — if not it's impossible. If it is, the answer is the number of…
General practice
Given an m x n grid with a list of black cell coordinates, compute how many 2x2 sub-blocks contain exactly 0..4 black cells; the challenge…
General practice
Count ordered tuples (i, j, k) of distinct 2D points where j and k are equidistant from i; for each point build a frequency map…
General practice
Given counts of tomato and cheese slices, find nonnegative integers (jumbo, small) so that 4*tomatoes_per_jumbo+2*tomatoes_per_small equals tomatoSlices and jumbo+small equals…
General practice
Given a list of phone-call records forming a directed (possibly time-ordered or multi-edge) graph, count how many call chains or interactions connect two specified persons…
General practice
Count how many times consecutive characters in string s correspond to different physical keys, treating uppercase and lowercase of the same letter as the same…
General practice
Count how many comments each post has by grouping comment records by post_id and returning post_id with its comment_count. Ensure posts with no comments are…
General practice
Count how many positive integers divide both a and b — compute g = gcd(a, b) and return the number of divisors of g. With…
General practice
Given an m×n binary matrix, count how many axis-aligned rectangles have all four corner cells equal to 1. The core challenge is to efficiently count…
General practice
Given two valid dates in "YYYY-MM-DD" format between 1971 and 2100, compute the absolute number of days between them, correctly accounting for leap years and…
General practice
Given a year and month, return how many days are in that month, correctly handling February via leap-year rules (year divisible by 4 but not…
General practice
Count the number of length-n sequences of values 1..k whose sum equals target, returning the count modulo 1e9+7. This is a classic DP/counting problem (bounded…
General practice
Extract all contiguous digit substrings from the input string, normalize them by removing leading zeros (treating empty as "0"), and return the count of distinct…
General practice
Count how many distinct integers g exist such that some non-empty subsequence of the given array has GCD equal to g. Input size can be…
General practice
Count how many times the digit '1' appears in all integers from 0 to n; the challenge is to derive an O(log n) solution by…
General practice
Repeatedly pair and remove the current minimum and maximum from an even-length array, compute each pair's average (a+b)/2, and return how many distinct averages occur…
General practice