Skip to content

Commit

Permalink
添加 206反转链表 Kotlin实现
Browse files Browse the repository at this point in the history
  • Loading branch information
GuoDuanLZ committed Aug 7, 2021
1 parent 91c6ecd commit 9dd846e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion problems/0206.翻转链表.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,20 @@ def reverse(pre, cur)
reverse(cur, tem) # 通过递归实现双指针法中的更新操作
end
```

Kotlin:
```Kotlin
fun reverseList(head: ListNode?): ListNode? {
var pre: ListNode? = null
var cur = head
while (cur != null) {
val temp = cur.next
cur.next = pre
pre = cur
cur = temp
}
return pre
}
```

-----------------------
* 作者微信:[程序员Carl](https://mp.weixin.qq.com/s/b66DFkOp8OOxdZC_xLZxfw)
Expand Down

0 comments on commit 9dd846e

Please sign in to comment.