We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
So many problems here. Your loop will only ever run if head.next points to itself. When it actually does run it would be infinite if head is not None since you never reassign current. Also since_scale is set to 0 and then the only operation you do to it is multiplication, which means it remains 0.
Amazingly this passes the test cases which shows how inadequate they are.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Linked Lists: Detect a Cycle
You are viewing a single comment's thread. Return to all comments →
So many problems here. Your loop will only ever run if
head.next
points to itself. When it actually does run it would be infinite ifhead
is notNone
since you never reassigncurrent
. Alsosince_scale
is set to 0 and then the only operation you do to it is multiplication, which means it remains 0.Amazingly this passes the test cases which shows how inadequate they are.