Data Structures & AlgorithmsHardTCS NQT Digital · Product Company SDE

Problem: Starting from 3, you may apply two operations: "+1" or "×2". What is the minimum number of operations needed to reach exactly 50?

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

Correct answer: A. 5

BFS over the value graph finds the fewest operations, bounding values to avoid runaway growth. Greedy halving from 50 back to 3 can take a different number of steps when the parity misleads.

More Coding Interview Problems questions

Exams that ask this topic