Plz check the while condition

i am not able to write the terminating condition in while loop
pz help

u will start searching from top right (i,j).

so u termination condition should be i>=n || j<0


not working

see that is ur termination condition.
inside while loop u should specify condition ,till when ur while loop should run.
so it should be while( (i<n && j>=0 ) n in ur case should be 3

check ur updated code-> https://ide.codingblocks.com/s/230603