static void leftRotate(LinkedList list, int k) {
if (list == null) {
return;
}
ListNode head = list.head;
ListNode current = head;
int count = 1;
while (current != null && count < k) {
count++;
current = current.next;
}
// If current is NULL, k is greater than or equal to count
// of nodes in linked list. Don't change the list in this case
if (current == null) {
return;
}
// current points to kth node. Store it in a variable.
// kthNode points to node 40 in the above example
ListNode kthNode = current;
// current will point to last node after this loop
// current will point to node 60 in the above example
while (current.next != null) {
current = current.next;