206. Reverse Linked List
Solution
Implementation
class Solution {
fun reverseList(head: ListNode?): ListNode? {
var current: ListNode? = head
var next: ListNode? = null
while (current != null) {
val temp = current.next
current.next = next
next = current
current = temp
}
return next
}
}