kucheasysa

Algoverse_adesh_37

Jul 6th, 2024
868
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. # Definition for singly-linked list.
  2. # class ListNode:
  3. #     def __init__(self, x):
  4. #         self.val = x
  5. #         self.next = None
  6.  
  7. class Solution:
  8.     def detectCycle(self, root: Optional[ListNode]) -> Optional[ListNode]:
  9.         n=1000000
  10.         while( root!=None and root.val!=1000000):
  11.             root.val=1000000
  12.             root=root.next
  13.         return root
Advertisement
Add Comment
Please, Sign In to add comment