如何逆转链表呢?本篇介绍两种常见方法:
- 遍历
- 递归
遍历
1 | private static Node reverseHead(@Nonnull Node head) { |
递归
1 | private static Node reverseByRecur(Node current) { |
如何逆转链表呢?本篇介绍两种常见方法:
1 | private static Node reverseHead(@Nonnull Node head) { |
1 | private static Node reverseByRecur(Node current) { |