Not passing all test cases

i think that my code for this question is correct as i have also seen by downloading all the test cases and matching it with my code output but when i am submitting the code only one test case is passing and rest all are getting rejected.

my code is saved at

kindly tell the problem in the code

in the loop while(i < j) you have used 3 if’s but instead you should you if else if and else,
Corrected code: