Incorrect answer

Hey @tushaartiwari1997
Your condition for j==ng was incorrect. You need to penalise for a wrong situation encountered. So you need to increase value returned for wrong situation like below.
if(j == ng)
return Integer.MAX_VALUE/2;

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

Hey @tushaartiwari1997
You opened the doubt again. How can I help you ?

Still getting the wrong answer

I have made the suggested changes here. See this.