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,826–1,850
Count the number of index triplets i<j<k in an array of unique ratings such that the ratings form a strictly increasing or strictly decreasing sequence…
General practice
Given a string of pressed keys (digits 2–9), count how many original letter messages could produce it, where consecutive identical digits can be grouped into…
General practice
Count the number of distinct convex quadrilaterals (trapezoids) that can be formed from given points such that at least one pair of opposite sides is…
General practice
Count the number of 4-point subsets that form a trapezoid — i.e., a convex quadrilateral with at least one pair of parallel sides — from…
General practice
Count placements of houses on two independent rows of n plots so that no two houses are adjacent on the same side; this reduces to…
General practice
Count how many integers in the inclusive string range [l, r] have non-decreasing digits when written in base b. This requires digit-DP / combinatorial counting…
General practice
Count how many integers x in [0, 10^n) have all distinct digits. This is a combinatorics problem: compute counts for each digit-length by using permutations…
General practice
Given n, count how many non-negative integers less than 10^n have all distinct digits (no repeated digits), including 0 and shorter numbers. The core challenge…
General practice
Convert each digit of the input number into its corresponding alphabet letter and return how many of those mapped letters occupy odd positions in the…
General practice
Count how many integers in the inclusive range [num1, num2] (given as strings) have a digit-sum between min_sum and max_sum; this is solved with digit-DP…
General practice
Count the subarrays where the number of elements satisfying nums[i] % modulo == k is itself congruent to k modulo modulo. Reduce to prefix counts…
General practice
Given n teams that play rounds where each match eliminates one team (even rounds pair all teams, odd rounds leave one team advancing), compute the…
General practice
Count the number of subarray sums within [lower, upper] — equivalently, count pairs of prefix sums whose difference lies in [lower, upper]. With n up…
General practice
For each element in an integer array, return how many elements to its right are smaller than it. With n up to 1e5 this requires…
General practice
Count the number of sub-multisets (you may take each value 0..occurrence times) whose element sum lies in [l, r], returning the result modulo 1e9+7. Algorithmically…
General practice
Count the number of substrings of a lowercase string that contain each of the five vowels (a, e, i, o, u) at least once and…
General practice
Count the number of substrings of a given lowercase string that include each vowel (a, e, i, o, u) at least once and contain exactly…
General practice
Companies: Amazon
Array · Binary Search · Prefix Sum
Repeatedly subtract the smaller of two nonnegative integers from the larger (or subtract one from the other if equal) until one becomes zero, and return…
General practice
Given two integer arrays, count how many index pairs (usually i < j) satisfy a given relation that involves elements from both arrays (e.g., equality…
General practice
Given a string and a threshold d, count the number of pairs of substrings of the same length whose Hamming distance is at least d…
General practice
Given an undirected graph (allowing multiple edges), for each query q count pairs of nodes (a,b) with incident(a,b) = deg[a] + deg[b] − commonEdges(a,b) >…
General practice
Count unordered pairs of points (i<j) whose distance defined as (xi XOR xj) + (yi XOR yj) equals k; with n up to 50k and…
General practice
Count the number of pairs of words that contain exactly the same set of unique characters (order and frequency don't matter). Group words by their…
General practice
Count the number of index pairs i<j such that hours[i] + hours[j] is a multiple of 24 — equivalently, whose remainders modulo 24 sum to…
General practice