import { ListNode } from './LinkList' ; param { ListNode } head param { number } k return { ListNode } function RotateRight ( head , k ) { if ( head === null || head . next === null ) { return head ; } let n ; let old_tail = head ; for ( n = 1 ; old_tail . next !== null ; n ++ ) { old_tail = old_tail . next ; } old_tail . next = head ; let new_tail = head ; for ( let i = 0 ; i < ( n - k % n - 1 ) ; i ++ ) { new_tail = new_tail . next ; } let new_head = new_tail . next ; new_tail . next = null ; return new_head ; } export default RotateRight ;