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 1,751–1,775
Count subarrays of length >= 3 where the smaller endpoint is strictly greater than every interior element — equivalently, count pairs (i, j) with j…
General practice
Companies: Google
Array · Counting · Hash Table · Math
Count how many cells belong to at least one horizontal substring (left-to-right, wrapping from end of a row to the first column of the next…
General practice
Count the number of assignments where each of n monkeys independently steps to a neighboring vertex (2^n total) that produce at least one collision; the…
General practice
Given a string of directions for cars moving at equal speed on an infinite road, compute the total collisions where opposite-moving cars collide (+2) and…
General practice
Count how many distinct strings appear exactly once in both input string arrays — i.e., return the number of strings whose frequency is 1 in…
General practice
Count the number of contiguous subarrays whose set of distinct elements equals the total number of distinct elements in the entire array. The core challenge…
General practice
Count the number of contiguous substrings where every distinct character appears exactly k times and every adjacent pair of characters differs by at most 2…
General practice
Count the connected components of a graph where nodes are the given numbers and an edge exists between a and b iff lcm(a,b) ≤ threshold…
General practice
Given unique building coordinates on an n×n grid, count how many buildings have at least one other building strictly above, below, left, and right (i.e.…
General practice
Given two inclusive date ranges in the same non-leap year (dates as "MM-DD") for Alice and Bob, return the number of days they are in…
General practice
Companies: Google
Dynamic Programming · Math
Starting from n, repeatedly add any i in [1,n] for which some current board value x satisfies x % i == 1, and after many…
General practice
Count the occurrences of each value in the array, find the maximum frequency, and return the total number of elements whose values occur with that…
General practice
Count how many elements have both a strictly smaller and a strictly greater element in the array — equivalently, count elements whose value is strictly…
General practice
Count the number of index pairs (i < j) where the elements are equal and the product i * j is divisible by k —…
General practice