Data Structures & AlgorithmsModerateCAT · TCS NQT
Problem: How many subsets of {1, 2, 3, 4, 5, 6} contain exactly two odd numbers?
- A. 15
- B. 3
- C. 24
- D. 64
Correct answer: C. 24
Choose 2 of the odds {1, 3, 5} in 3 ways and any subset of the evens in 2³ = 8 ways: 24. C(6,2) = 15 picks any two numbers, 3 forgets the evens, and 64 counts all subsets.
More Coding Interview Problems questions
- Problem: The product of the first 6 positive odd numbers 1·3·5·7·9·11 is computed. What is that product's value modulo 100?
- Problem: A cyclic array [1, 2, 3, 4, 5] is rotated so that the element at index 0 becomes the element at index 2 (rotate left by 2). What…
- Problem: Starting from 5 on a number line, you may jump +2 or +3 each turn and must land exactly on 25. How many distinct jump sequences…
- Problem: A rectangle of 12 by 18 units is cut into the largest possible identical squares that tile it exactly. How many such squares are…
- Problem: The number 720 is written as a product of primes. What is the sum of its distinct prime factors?
- Problem: A grid of 2 rows and 5 columns is numbered row by row from 1. Each cell (r, c) holds (r·5 + c + 1). What is the value of the cell…