
[LeetCode] 61. Rotate List, Medium
·
CodingTest/LeetCode
1. 문제단일 연결리스트와 정수 k가 주어질 때, k만큼 오른쪽으로 회전한 리스트를 반환하라.2. 해결/** * Definition for singly-linked list. * class ListNode { * val: number * next: ListNode | null * constructor(val?: number, next?: ListNode | null) { * this.val = (val===undefined ? 0 : val) * this.next = (next===undefined ? null : next) * } * } */function rotateRight(head: ListNode | null, k: number): Lis..