Error in program


ans is coming right but testcases not passing

Modified Code

mistakes

  1. Print end after each testcase
  2. int z=0 should comes inside while loop

look at modified code it is passing all testcase now

i hope this helps
if yes hit a like and don’t forgot to mark doubt as resolved
if you have more doubts regarding this feel free to ask