var rotateRight = function(head, k) { if(!head) return head let list = head while(k--){ list = doRotate(list) } return list };
var doRotate = function(head){ let cur = head while(cur.next&&cur.next.next){ cur = cur.next } if(!cur.next) return cur cur.next.next = head let z = cur.next cur.next = null return z }
var rotateRight = function(head, k) { if(!head) return head let i = 1 let cur = head while (cur.next){ cur = cur.next i++ } let con = k%i let list = head while(con--){ list = doRotate(list) } return list };
var doRotate = function(head){ let cur = head while(cur.next&&cur.next.next){ cur = cur.next } if(!cur.next) return cur cur.next.next = head let z = cur.next cur.next = null return z }