Data Structures & AlgorithmsModerateCAT · TCS NQT
Problem: In a list of 6 candidates, each candidate is either rejected or accepted. The number of ways to accept at least 2 and at most 4 candidates is what value?
- A. 20
- B. 50
- C. 57
- D. 64
Correct answer: B. 50
C(6,2) + C(6,3) + C(6,4) = 15 + 20 + 15 = 50. Exactly 3 gives 20, 'at least 2' with no upper limit gives 57, and 64 counts every subset.
More Coding Interview Problems questions
- Problem: A sequence is generated from 1 by repeatedly applying: x → x + (x mod 4). Starting at x = 1, what is the value after 6 steps?
- Problem: An array of length 7 holds the values 0 to 6 in some order; the position of value k is pos[k]. For the array [2, 0, 3, 6, 1, 5…
- Problem: From the string "3a7b2c" the digits are extracted and summed. What is the sum of the digits?
- Problem: The number of ways to place 3 identical red balls and 2 identical blue balls in a row of 5 positions is what value?
- Problem: The matrix [[1,2],[3,4]] is raised to the power 3 (matrix multiplication, not element-wise). What is the entry in row 0, column 0…
- Problem: Starting from the empty binary string, the value of the string "1011" read in base 2 is computed, then 3 is added. What is the…