Data Structures & AlgorithmsModerateTCS NQT · CAT

Problem: The numbers 1 to 20 are split into odd numbers and even numbers. What is the absolute difference between the sum of the odd numbers and the sum of the even numbers?

  1. A. 100
  2. B. 110
  3. C. 210
  4. D. 10

Correct answer: D. 10

Pair (1,2), (3,4), …, (19,20): each pair differs by 1, so the gap is 10 (110 − 100). 100 is the odd sum, 110 the even sum, and 210 the total.

More Coding Interview Problems questions

Exams that ask this topic