public static ListNode RotateRight(ListNode head, int k)
{
if (head==null||head.next==null||k==0)
{
return head;
}
//cannect the tail and head
int length = 1;
ListNode temp = head;
while (true)
{
if (temp.next==null)
{
temp.next = head;
break;
}
else
{
temp = temp.next;
length++;
}
}
temp = head;// this temp is head;(only one)
int steps = length - k % length - 1;
while (steps>0)
{
temp = temp.next;
steps--;
}
ListNode newHead = temp.next;
temp.next = null ;
return newHead;
}