Help ramu problem without using array

*i am getting compilation error in this code.and also time limit exceeded.how can i solve it without using array?

  • it is necessary to write the constraints given in the problem ?

hello @lovely
a)
have made some changes pls check.

b)
still some logical mistake is there pls refer ->

c)

yeah , constraints are necessary.

the output is still coming wrong.can u please check it again and i also checked out the video its logic is same but it is done using array.