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,926–1,950
Count how many subsequences of a given sequence/string satisfy the problem's "good" criterion (typically non-trivial pattern or property) — return the total (usually modulo…
General practice
Given n houses in a line with one extra edge between x and y, count for each k the number of ordered house pairs whose…
General practice
Count, for each k, the number of ordered pairs of nodes in a path graph of n houses with one extra shortcut edge (x,y) whose…
General practice
Count how many length-n arrays with values in [1, maxValue] satisfy arr[i] % arr[i-1] == 0 for all i — equivalently, count multiplicative/divisibility chains in…
General practice
Count the number of contiguous non-empty subarrays whose removal makes the remaining array strictly increasing (the empty array counts as strictly increasing). The core…
General practice
Count the non-empty contiguous subarrays whose removal makes the remaining array strictly increasing. With n up to 1e5, the task is to efficiently combine prefix/suffix…
General practice
Count the number of distinct orders in which all uninfected people can become infected when infection spreads only to adjacent people from the initially sick…
General practice
Count the permutations of [0..n-1] such that for each requirement (end_i, cnt_i) the prefix perm[0..end_i] has exactly cnt_i inversions, returning the result modulo 1e9+7. The…
General practice
Given an integer array and k, count indices i such that the element at i is "k-big" — i.e., there are at least k elements…
General practice
Count the number of subsets of a multiset of integers such that no two chosen elements differ by k. The challenge is to handle duplicate…
General practice
Count how many integers in [start, finish] have decimal representation ending with the given suffix s and whose every digit is ≤ limit; the core…
General practice
Given a string of English letters, return the number of distinct letters that appear in both lowercase and uppercase forms in the string.
General practice
Count the number of letters that appear in both lowercase and uppercase in the string and whose every lowercase occurrence appears before that letter's first…
General practice
Count the number of non-empty subsets whose product is square-free (no prime squared divides it) modulo 1e9+7. With nums[i] ≤ 30 and n ≤ 1000…
General practice
Given a binary string s (length ≤ 4×10^4), count substrings where the number of '1's is at least the square of the number of '0's…
General practice
Given an array of lowercase words and indices left and right, count how many strings in the inclusive range [left, right] start and end with…
General practice
Given Alice's fixed length-n sequence of moves in a rock-paper-scissors cycle (F beats E, W beats F, E beats W), count how many length-n sequences…
General practice
Given s1, s2 and repetition counts n1, n2, find the maximum m such that s2 repeated m (i.e., [s2, m]) can be obtained as a…
General practice
Starting from one colored cell on an infinite grid, every minute all uncolored cells adjacent to any colored cell become colored; determine the total number…
General practice
Count the number of triplets (i, j, k) with 0 ≤ i < j ≤ k < n such that the XOR of arr[i..j-1] equals…
General practice
Count the number of index triplets (i<j<k) in an integer array such that the XOR of the three elements has an even number of set…
General practice
Given an integer array, count the number of index triplets whose bitwise XOR has an even number of 1-bits. Key insight: parity of popcount is…
General practice
Given an m x n grid with guards and walls, determine how many empty cells are not seen by any guard, where each guard observes…
General practice
Given n friends with complete preference lists and a fixed pairing, count how many people are "unhappy" because there exists another person they prefer over…
General practice
Compute the sum, over all substrings of s, of how many characters appear exactly once in that substring. The core challenge is to count each…
General practice