Data Structures & AlgorithmsHardICPC regional · CAT
Problem: How many 4-element subsets of {1, 2, ..., 8} have a sum that is a multiple of 5?
- A. 52
- B. 14
- C. 7
- D. 11
Correct answer: B. 14
Enumerating the 70 four-subsets of 1..8 finds 14 with sum ≡ 0 (mod 5). All subset sizes give 52, sum exactly 20 gives 7, and 3-subsets give 11.
More Coding Interview Problems questions
- Problem: The array [4, 9, 16, 25] has its square roots summed. What is the sum of the square roots of these four numbers?
- Problem: A grid has 5 cells in a row, each painted red or blue. How many colourings have no two adjacent cells of the same colour?
- Problem: What is the largest integer n such that n! has at most 3 trailing zeros in base 10?
- Problem: The matrix [[2,0],[0,3]] is raised to the power 4 (matrix power). What is the sum of all entries of the result?
- Problem: A word is "statistics". How many distinct letters appear at least twice in it?
- Problem: A sorted array [2, 3, 5, 7, 11, 13, 17, 19] is searched for 11 using binary search with mid = (lo + hi) // 2 over the inclusive…