Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: For the words ["sleep", "steep", "sheep", "creep"] (all of length five), how many unordered pairs differ in exactly one letter position?

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

Correct answer: B. 3

Compare each pair position by position. 'sleep', 'steep' and 'sheep' pairwise differ in one position, while 'creep' differs from each of them in two positions, so the answer is three.

More Coding Interview Problems questions

Exams that ask this topic