Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA

How many integers from 1 to 50 inclusive have exactly two 1-bits in binary and are even?

  1. A. 11
  2. B. 15
  3. C. 10
  4. D. 5

Correct answer: C. 10

Two set bits with an even value means the lowest bit is zero, so the second bit position is at least 1. Count the qualifying values by checking each number in 1..50.

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

Exams that ask this topic