class Solution {
public ListNode rotateRight(ListNode head, int k) {
if(head==null || k == 0 ) return head;
ListNode p = head;
int len = 0;
while(p !=null){
p = p.next;
len++;
}
k = k % len;
if(k == 0 ) return head;
ListNode f = head;
ListNode s = head;
while(k >0){
f = f.next;
k--;
}
while(f.next!=null){
f = f.next;
s = s.next;
}
// head s a f
ListNode a = s.next;
f.next = head;
s.next = null;
return a;
}
}