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,926–3,950
Given an m×n binary grid where '1's are security devices, count laser beams between pairs of devices on different rows such that every row between…
General practice
Count how many strictly increasing subsequences of maximum possible length exist in the given array. The core challenge is tracking, for each element, the length…
General practice
Count how many strings in words appear as subsequences of a given string s (characters in order but not necessarily contiguous). The challenge is to…
General practice
Given a rooted tree with a lowercase label on each node, return for every node how many nodes in its subtree have the same label…
General practice
Treat the network as an undirected graph: if the total number of edges is less than n-1 return -1, otherwise compute the number of connected…
General practice
Count how many index pairs of rectangles share the same width:height ratio. Normalize each (w,h) to its reduced form (e.g., divide by gcd) and use…
General practice
Count the ordered pairs (i, j), i ≠ j, of digit-strings from nums whose concatenation equals the given target. Key idea: consider every split of…
General practice
Transform to A[i] = nums1[i] - nums2[i] and count pairs i < j with A[i] <= A[j] + diff (equivalently A[i] - A[j] <= diff)…
General practice
Given an n×n board with digits, obstacles 'X', start 'S' (bottom-right) and end 'E' (top-left), find the maximum sum of digits collectible moving only up…
General practice
Count how many people know a secret after n days when each person starts sharing every day beginning delay days after learning it and stops…
General practice
Given an m×n grid of heights representing people, determine for each person how many other people they can see along the four cardinal directions where…
General practice
Count how many subsets of branches can be closed so that every pair of remaining branches has weighted shortest-path distance ≤ maxDistance (empty or single-node…
General practice
Implement a RecentCounter supporting ping(t) that records a strictly increasing timestamp and returns how many requests occurred in the inclusive window [t-3000, t]. Core…
General practice
For each rectangle, its largest possible square side is min(length, width); find the maximum of these minima across all rectangles and return how many rectangles…
General practice
Count the number of substrings in a given string whose first and last character are the same. This reduces to aggregating contributions per character (single-character…
General practice
Count the number of contiguous runs of non-space characters in a given string and return that count. Handle empty strings and multiple/leading/trailing spaces (i.e., ignore…
General practice
Count how many permutations of 1..n satisfy that for every position i the placed value and i are "self-divisible" (e.g., the value divides i or…
General practice
Given an array of fixed-format 15-character strings where chars 0–9 are phone, char 10 is gender, chars 11–12 encode age, count how many passengers have…
General practice
Count the number of ways to choose exactly k non-overlapping line segments on n collinear integer points (points 0..n-1), where each segment covers at least…
General practice
Given an integer array, count triplets of indices (i, j, k) such that exactly one element of the triplet divides both of the other two…
General practice
Count all contiguous subarrays (periods) where each day's price is exactly one less than the previous day (single-day periods count). This is equivalent to finding…
General practice
Simulate a robot moving on a 2D grid with obstacles (and/or a sequence of movement/rotation commands) and compute how many unique grid cells it cleans…
General practice