public ListNode rotateRight(ListNode head, int k) {
if(k==0||head==null||head.next==null) return head;
List<ListNode> list = new ArrayList<>();
ListNode tmp = head;
while(tmp != null) {
list.add(tmp);
tmp = tmp.next;
}
int len = list.size();
k%=len;
if(k == 0) return list.get(0);
list.get(len-1).next = list.get(0);//形成一个闭环
list.get(len-k-1).next = null;
return list.get(len-k);
}