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,951–3,975
Count distinct permutations of nums where every adjacent pair sums to a perfect square; the core challenge is to build a graph of valid adjacencies…
General practice
Given a binary string s, count the number of steps to reduce the represented number to "1" by repeatedly dividing by 2 when it's even…
General practice
Count how many operations it takes to reduce a nonnegative integer to zero if you must divide by 2 when it's even and subtract 1…
General practice
Return the count of strings in patterns that occur as contiguous substrings of word (counting duplicate patterns separately).
General practice
Count the number of length-n lowercase strings whose character multiset contains at least two 'e's, one 'l' and one 't' (so they can be rearranged…
General practice
Given two lists describing current and desired student assignments or attributes, compute the minimum number of student replacements required to transform the current…
General practice
Count how many intervals [startTime[i], endTime[i]] contain queryTime (inclusive). This is a straightforward counting problem over at most 100 intervals, typically solved by a…
General practice
Count how many contiguous subarrays of length k have an average ≥ threshold — equivalently, how many sliding windows have sum ≥ k×threshold. This is…
General practice
Count how many subarrays of an integer array have an odd sum; because n can be up to 1e5, this requires an O(n) approach using…
General practice
Count the number of contiguous subarrays whose product is even — equivalently, subarrays that contain at least one even element. Solve in O(n) by complementary…
General practice
Count how many contiguous subarrays of length m+1 in nums have adjacent pairs that match a given pattern of -1/0/1 (interpreted as <, ==, >…
General practice
Count how many length-(m+1) subarrays of nums satisfy the given adjacent-comparison pattern (pattern[k] specifies whether nums[i+k+1] is >, =, or < nums[i+k]). Reduce to a…
General practice
Count the contiguous subarrays whose bitwise AND equals k; the key observation is that AND values are non‑increasing as you extend a subarray, so there…
General practice
Count the number of contiguous subarrays whose maximum element lies in the inclusive range [left, right]. Solve efficiently with a linear scan by counting subarrays…
General practice
Count the number of contiguous subarrays whose greatest common divisor equals k. Exploit that the running GCD of a subarray only decreases, so for each…
General practice
Count the number of contiguous subarrays whose least common multiple equals k, using the key observation that any subarray LCM must divide k so you…
General practice
Count the number of non-empty subsequences of an integer array whose sum is odd (answer may be large — typically return modulo 1e9+7). The core…
General practice
Count how many substrings of a string (only 'a', 'b', 'c') contain at least one of each character; the core challenge is to do this…
General practice
Count how many substrings of a (typically binary) string have the counts of two characters in a given fixed ratio p:q. The core challenge is…
General practice
Count how many substrings of a binary string consist entirely of '1's (return the result modulo 1e9+7). The core challenge is to compute, in linear…
General practice
Given a list/table of rides with driver_id and passenger_id, compute for each person who has driven how many times they appear as a passenger by…
General practice
Given visit records with start/end timestamps and transaction records with timestamps, compute for each visit how many transactions occurred within that visit's time window…
General practice
Given a list of directed trust relationships between customers and a target customer, determine how many distinct customers are reachable from that target (trusted directly…
General practice
Given an array of category labels and multiple queries asking how many distinct categories appear in a specified range (and possibly with updates), compute each…
General practice
Given an array of integers representing candy flavors and an integer K for how many candies are shared/removed, determine how many distinct flavors remain after…
General practice