Reverse Second Half of a Linked List
来源:互联网 发布:同志长得帅体验知乎 编辑:程序博客网 时间:2024/05/21 06:17
class ListNode {int val;ListNode next;ListNode(int x) { val = x; }}public class ReverseSecondHalfofLinkedList {public static ListNode reverseSecondHalf(ListNode head) {if(head == null || head.next == null)return head; ListNode slow = head, fast = slow.next; while(fast.next != null && fast.next.next != null) { slow = slow.next; fast = fast.next.next; } ListNode pre = null, cur = slow.next; while(cur != null) { ListNode next = cur.next; cur.next = pre; pre = cur; cur = next; } slow.next = pre; return head;}}
阅读全文
0 0
- Reverse Second Half of a Linked List
- Reverse Second Half of Linked List
- Reverse Second half of LinkedList Java实现
- reverse a linked list
- Reverse a linked list.
- Reverse a linked list
- Reverse A Linked List
- reverse a linked list
- Reverse a linked list
- reverse a linked list
- [leetcode] Reverse a linked list
- 150 - reverse a linked list;
- LeecCode Reverse Linked List; Reverse a singly linked list.
- No. 18 - Reverse a Linked List
- 【Hackerrank】Reverse a doubly linked list
- HackerRank Reverse a linked list(逆置链表)
- Reverse a singly linked list python
- 第16题 reverse every K elements of a linked list
- 开发者山行图,找到你的收入和位置
- 创建自己的搜索引擎,利用google进行站内搜索
- Android Studio上进行NDK编程之Hello world
- static 深入理解
- Tensorflow--Day 1
- Reverse Second Half of a Linked List
- String与StringBuffer的区别
- Minimum Path Sum of a Binary Tree
- 抽象类和接口的区别
- 面向对象重写(override)与重载(overload)区别
- react-native windows搭建运行环境
- Array和ArrayList的异同点
- java线程池
- Array与Arrays的区别