https://leetcode.com/problems/rotate-list/description/?envType=study-plan-v2&envId=top-interview-150

def rotateRight(self, head: Optional[ListNode], k: int) -> Optional[ListNode]:
  if not head: return head

  length = 0
  ptr = head
  while ptr:
      ptr = ptr.next
      length += 1
  k = k%length

  slow, fast = head, head
  while k:
      fast = fast.next
      k -= 1

  while fast.next:
      slow = slow.next
      fast = fast.next

  fast.next = head
  head = slow.next
  slow.next = None
  return head