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,801–1,825
Group numbers 1..n by their digit-sum and count how many digit-sum groups achieve the maximum size. (Effectively compute digit-sum frequencies and return the number of…
General practice
Count the integer-coordinate points that lie inside the union of up to 200 integer-centered circles (points on the circumference count), i.e., compute the number of…
General practice
Simulate the time-ordered events while maintaining each user's online/offline status (OFFLINE makes a user offline for 60 units, and status changes at a timestamp apply…
General practice
Given an m x n matrix sorted in non-increasing order both row- and column-wise, return the number of negative entries; exploit the matrix's monotonicity to…
General practice
Count pairs i<j where nums[i] + rev(nums[j]) == nums[j] + rev(nums[i]); the condition is equivalent to nums[i] - rev(nums[i]) == nums[j] - rev(nums[j]), so the…
General practice
Given a binary tree, count how many nodes have a value equal to the sum of all values in their descendant nodes (i.e., the subtree…
General practice
Given a rooted tree of integer values, count the nodes that are "great enough" — typically meaning each node's value is at least the maximum…
General practice
Given a rooted binary tree as a parent array, compute for each node the score defined as the product of sizes of the connected components…
General practice
Companies: Infosys
Array · Depth-First Search · Dynamic Programming · Tree
Companies: Microsoft
Array · Dynamic Programming · Prefix Sum
Count how many subarrays can be turned non-decreasing with at most k +1-increment operations, where the minimal cost for a subarray is the sum of…
General practice
Count how many index pairs (i, j) satisfy j - i != nums[j] - nums[i]; equivalently, good pairs have equal values of nums[k] - k…
General practice
Count the distinct permutations of a digit string (length ≤ 80, digits 0–9 with repeats) whose sum of digits at even indices equals the sum…
General practice
Given an array of positive integers, append the digit-reversal of each original element (note reversing drops leading zeros, e.g., 10 -> 1) and return how…
General practice
Count the total contiguous substrings whose characters are all equal by grouping consecutive identical characters and summing the number of substrings contributed by each run…
General practice
Given an array nums (n ≤ 16), determine the maximum bitwise OR value obtainable from any non-empty subset and return how many distinct index-based non-empty…
General practice
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
Count the number of index pairs (i < j) in an integer array whose absolute difference equals k. With n ≤ 200 and values in…
General practice
Given an undirected tree and a set of directed parent guesses (each guess orients an existing edge u→v), count how many choices of root make…
General practice
For each query point, count how many origin-anchored rectangles (0,0)-(li,hi) satisfy li >= x and hi >= y. Key observation: heights are bounded (<=100), so…
General practice
Count the number of subsequences that consist of a positive number of 0s followed by a positive number of 1s then a positive number of…
General practice