Data Structures & AlgorithmsModerateTCS NQT · Accenture

Problem: From the list of integers [10, 15, 20, 25, 30], remove the elements that are divisible by 4 or by 6 (the rest remain in order). What is the sum of the remaining elements?

  1. A. 50
  2. B. 100
  3. C. 80
  4. D. 70

Correct answer: A. 50

20 (by 4) and 30 (by 6) are removed, leaving 10 + 15 + 25 = 50. Removing only those divisible by both (none) gives 100, removing only multiples of 4 gives 80, and only multiples of 6 gives 70.

More Coding Interview Problems questions

Exams that ask this topic