I know that. If i is n-1, j will be n but it should be less than n it won’t work.
My Solution : CodeChef: Practical coding for everyone Ps: just optimising