Data Structures & AlgorithmsVery hardICPC regional · Amazon SDE OA

Sum the largest power of two that divides each element of [12, 40, 7, 24]. What is the total?

  1. A. 22
  2. B. 41
  3. C. 21
  4. D. 20

Correct answer: C. 21

The largest power of two dividing x is x AND -x: 12 gives 4, 40 gives 8, 7 gives 1, 24 gives 8. The total is 21.

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

Exams that ask this topic