I AM GETTING THE WRONG DIAMETER

I am getting the diameter for the same test case as used in the video as 8 but it should be 6 kindly look into my code

*input case = 8 10 1 -1 -1 6 9 -1 -1 7 -1 -1 3 -1 14 13 -1 -1 -1

Hello @av8055 check this;


i have corrected your code and commented the mistake:

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.