Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: Find the number of distinct strings obtained by reading the grid of letters ab cd moving right or down from the top-left, where each step appends the letter of the cell entered (the start letter counts). How many different strings can be produced?

  1. A. 3
  2. B. 1
  3. C. 2
  4. D. 4

Correct answer: C. 2

There are only two monotone paths in a 2×2 grid, and each spells a different string. Counting cells in the grid overstates the answer because paths are what matter.

More Coding Interview Problems questions

Exams that ask this topic