Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

What is the smallest integer greater than 13 that has the same number of 1-bits as 13 in binary?

  1. A. 11
  2. B. 19
  3. C. 22
  4. D. 14

Correct answer: D. 14

13 = 1101₂; the next number with three set bits moves the lowest movable 1 up one place: 1110₂ = 14. 11 = 1011₂ is the previous such number, and 19 = 10011₂ and 22 = 10110₂ also have three bits but are not the smallest above 13.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic