Data Structures & AlgorithmsVery hardICPC regional · Amazon SDE OA

How many perfect squares lie in the range [50, 250] inclusive?

  1. A. 9
  2. B. 7
  3. C. 8
  4. D. 11

Correct answer: C. 8

The squares are 64, 81, 100, 121, 144, 169, 196, 225, 256 (too big), so the count is 8 from 8^2 = 64 to 15^2 = 225. Using the open interval drops nothing here, so the endpoints must be checked exactly.

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

Exams that ask this topic