Cycle detection and removal problem

I am not able to pass test cases can you please let me know where i m getting wrong

hello @rahul.aggarwal000005
image
it should != in place of ==

still many test cases are not passing

where u r submitting?

this part has some issue.
image

change to this ->
image

ur updated code ->