I am having trouble understanding this solution

Hi there,

I took the introductory test in codechef-unacademy ICO learning program, and watched the first lecture (introduction to algo. - 1) which had detailed solutions to the tests’ questions. I am having confusion with the solution of problem 4/5/6 in the test, which is as follows :

In the solution, Aryan sir finds the size of the range using the formula - (2k+1)^2. I feel I did was not able to understand the following points :

  • how did he come up with this formula?
  • why did he square it (^2)?
  • and why did he add 1 to it?

I would really appreciate if anyone is able to clear my confusions, as it would be very helpful to me :slightly_smiling_face: Thanks a lot!