Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: In how many ways can 100 be written as a sum of two perfect squares x² + y² with 0 ≤ x ≤ y (unordered, non-negative)?

  1. A. 2
  2. B. 3
  3. C. 1
  4. D. 4

Correct answer: A. 2

Count pairs with 0 ≤ x ≤ y and x² + y² = 100. The representations 0² + 10² and 6² + 8² are the ones this condition admits; ordered pairs would double the count except for symmetric cases.

More Coding Interview Problems questions

Exams that ask this topic