Hel for this problem

can we do this without array approach.

Can you please elaborate what are you trying to say. What do you want to use and how do you want to solve this.
@akshat2806