Floyd Algo Doubt

Hi,

I’ve doubt in floyd algo that i’ve written two functions to for the same algo one is better than the other. Optimised named function is better than Unoptimised named function. But the correct ans which I’m getting is through unoptimised one not the optimised one. So can u pls go through my code and tell me where logic is wrong.

Link: https://ide.codingblocks.com/s/678437

Thanks

hi @kartikey.rajput0071,
suppose there is no cycle then u need to return NULL that u r doing in unoptimsed function not in optimsed one, here u r returning slow if answer is not found, try changing that part maybe u can keep a bool variable that will tell if u found cycle if yes then only return slow else return NULL

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.