Data Structures & AlgorithmsModerateTCS NQT Digital · Infosys

Problem: Find the smallest positive integer x such that floor(x/2) + x is at least 50.

  1. A. 33
  2. B. 34
  3. C. 17
  4. D. 50

Correct answer: B. 34

f(33) = 16 + 33 = 49 < 50 and f(34) = 17 + 34 = 51 ≥ 50, so x = 34. Returning the last failing x gives 33, 17 is floor(34/2), and 50 ignores the floor(x/2) term.

More Coding Interview Problems questions

Exams that ask this topic