Data Structures & AlgorithmsModerateTCS NQT · Accenture
Problem: The number of subsets of {1, 2, 3, 4} whose elements sum to exactly 5 (the empty set is excluded) is what value?
- A. 3
- B. 1
- C. 2
- D. 4
Correct answer: C. 2
The subsets with sum 5 are {1,4} and {2,3}, so the count is two.
More Coding Interview Problems questions
- Problem: The number of ways to make 15 using coins of values 2, 3 and 5, where the order of coins does not matter, is what value?
- Problem: The sum of the numbers obtained by repeatedly removing the first and last elements of [1, 2, 3, 4, 5, 6, 7, 8] and adding them as…
- Problem: What is the remainder when 2^100 is divided by 9?
- Problem: The sum of all three-digit palindromic numbers (100–999) is what value?
- Problem: How many integers n with 0 ≤ n ≤ 255 have exactly four 1-bits in their binary representation?
- Problem: What is the largest power of 2 that is less than or equal to 1000?