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 4,551–4,575
Count the number of contiguous subarrays that contain exactly k distinct integers. A common approach is to use two-pointer/sliding-window with a frequency map to compute…
General practice
Given an array of non-negative integers and an integer K, count how many subarrays have bitwise XOR >= K. The core challenge is to efficiently…
General practice
Given entries like "9001 discuss.hellointerview.com", parse each count and domain, generate all parent subdomains (e.g., "hellointerview.com", "com"), and aggregate visit…
General practice
Implement a class that stores an m×n integer matrix and supports assigning a given value to every cell in an axis-aligned subrectangle and retrieving the…
General practice
For each x from 1..n, determine whether the target k can be formed as a subsequence sum from the array obtained by replacing each nums[i]…
General practice
Given strings s and t (lengths up to 1e5), find the minimum length of a contiguous substring of t to remove (score = removed length…
General practice
Count the number of length-5 subsequences whose middle element is the unique mode (i.e., appears strictly more times than any other value in the five)…
General practice
Count the number of odd-length subsequences of an array whose central element (by subsequence order) is the strictly most frequent value — i.e., the unique…
General practice
Generate all distinct subsets (the power set) from an integer array that may contain duplicates; the core challenge is to enumerate all combinations without producing…
General practice
Given string s and pattern p containing exactly one '*' that can match any (possibly empty) sequence, determine whether p can be turned into a…
General practice
Find the maximum possible difference between counts of any two lowercase letters over all contiguous substrings of s — i.e., the largest (count(a) - count(b))…
General practice
Given a binary string s and many queries [first, second], for each query find the shortest substring whose integer value val satisfies val ^ first…
General practice
Count how many contiguous substrings of length three in s contain three distinct characters. This is a straightforward fixed-size sliding-window / uniqueness-check problem (s…
General practice
Count the number of substrings of a given string whose first and last character are the same (including single-character substrings). The challenge is to do…
General practice
Given a positive integer n, compute and return (product of its decimal digits) − (sum of its decimal digits). This is a simple digit-extraction problem…
General practice
Choose a set of nodes whose subtree values are negated to maximize the total sum, with the constraint that any two inverted nodes that are…
General practice
Check whether subRoot appears as an exact subtree of root by finding some node in root whose entire descendant structure and node values match subRoot…
General practice
Two players alternately remove a chosen node's entire subtree from a recursively defined "Fibonacci tree" (whose sizes follow Fibonacci numbers); the last player to move…
General practice
For each spell, count how many potions produce a product >= success by computing the minimum required potion strength and efficiently counting qualifying potions (typically…
General practice
Two players alternately replace '?' in an even-length digit string with 0–9; Alice wins if the final sums of the first and second halves differ…
General practice
Repeatedly remove each row's largest remaining element and add the maximum of those removed to your score until the matrix is empty; return the final…
General practice
Compute the sum of all integers in [1, n] that are divisible by 3, 5, or 7. A common approach uses inclusion–exclusion with arithmetic-series sums…
General practice
Given a sorted array, compute for each index the sum of absolute differences between nums[i] and all other elements. The sorted order lets you compute…
General practice