MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / reverse

Function reverse

Hackerrank_problems/Reverse Linked List/solution.py:40–60  ·  view source on GitHub ↗

check if its empty list or not

(head)

Source from the content-addressed store, hash-verified

38
39
40def reverse(head):
41 """
42 check if its empty list or not
43 """
44 if head is None:
45 return None
46 prev = None
47 now = head
48 temp = head.next
49 """
50 make recursion until tail
51 but take the data in the previous node
52 """
53 while now is not None:
54 now.next = prev
55 prev = now
56 now = temp
57 # go to the next node
58 if now is not None:
59 temp = temp.next
60 return prev
61
62
63if __name__ == '__main__':

Callers 3

solution.pyFile · 0.70
searchtrieFunction · 0.50
fFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected