Data Structures & AlgorithmsModerateCAT · TCS NQT

Problem: A bag contains 2 red, 3 green and 4 blue balls. How many ways are there to choose 3 balls so that all three have different colours?

  1. A. 84
  2. B. 24
  3. C. 9
  4. D. 144

Correct answer: B. 24

One ball of each colour: 2 · 3 · 4 = 24. C(9,3) = 84 ignores colours, adding gives 9, and multiplying by 3! treats the picks as ordered (144).

More Coding Interview Problems questions

Exams that ask this topic