Data Structures & AlgorithmsModerateCAT · TCS NQT Digital

Problem: How many 4-digit numbers (1000 to 9999) have all four digits distinct and in strictly decreasing order from left to right?

  1. A. 126
  2. B. 714
  3. C. 210
  4. D. 5040

Correct answer: C. 210

Any 4 distinct digits can be arranged in exactly one decreasing order, and 0 can only be last, so the count is C(10, 4) = 210. Excluding 0 gives C(9, 4) = 126, allowing equal neighbours gives 714, and 5040 counts all ordered distinct-digit choices.

More Coding Interview Problems questions

Exams that ask this topic