Data Structures & AlgorithmsHardProduct Company SDE · ICPC regional
Problem: A bitmask DP problem: count the subsets of {1, 2, ..., 10} whose sum is a multiple of 5 (the empty set counts, since its sum 0 is a multiple of 5).
- A. 207
- B. 208
- C. 204
- D. 104
Correct answer: B. 208
A DP over remainders mod 5 (each x adds dp[(r − x) mod 5]) gives 208 subsets including the empty set. Excluding the empty set gives 207, the estimate ⌊1024 / 5⌋ gives 204, and stopping at 9 elements gives 104.
More Coding Interview Problems questions
- Problem: An 8-bit unsigned counter starts at 250 and is incremented by 7 each step, wrapping modulo 256. How many increments until the…
- Problem: The Pascal triangle rows are numbered from row 0 (single 1). What is the sum of all entries in row 12 that are odd?
- Problem: Count the strings of length 4 over the alphabet {a, b, c} that contain no two adjacent equal characters and do not contain the…
- Problem: The number of inversions in a permutation of 1..8 given as [4, 7, 1, 8, 2, 6, 3, 5] is what value?
- Problem: On a tree with 9 nodes labelled 1–9, edges 1-2, 1-3, 2-4, 2-5, 3-6, 6-7, 6-8, 8-9, count the unordered pairs of nodes whose path…
- Problem: A string is a palindrome-partition target: what is the minimum number of cuts needed to split "abbacxcaxyyx" into palindromic…