Floyyd cycle tle in some test cases

I am getting tle in some test cases plz suggest correction

hello @coderajay03
pls check ur updated code here->

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.

Bhaiya can you please help me in solving the question printing all leaf nodes path from root I wrote code but there is slight error right tree not getting printed https://ide.codingblocks.com/s/378635 please suggest solution to this test case I used 8 10 1 -1 -1 6 9 -1 -1 7 -1 -1 3 -1 14 13 -1 -1 -1