Data Structures & AlgorithmsModerateTCS NQT · CAT · MBA placement

What is the largest integer k such that 1 + 2 + ... + k is at most 2023?

  1. A. 63
  2. B. 64
  3. C. 44
  4. D. 62

Correct answer: A. 63

The partial sums k(k+1)/2 grow monotonically, so binary search on k finds the largest one not exceeding n. Taking the integer square root (a common confusion with k²) gives a different value.

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

Exams that ask this topic