Rotate ListNode In K Groups
来源:互联网 发布:运营数据分析报告范文 编辑:程序博客网 时间:2024/05/16 14:18
K个节点一组,反转链表;
public ListNode rotate(ListNode head, int k) { if (head == null || head.next == null || k <= 1) { return head; } ListNode dummy = new ListNode(-1); dummy.next = head; ListNode pre = dummy, cur = head; int num = 0; while (cur != null) { num++; cur = cur.next; } if (num >= k) { cur = pre.next; for (int i = 1; i < k; i++) { ListNode next = cur.next; cur.next = next.next; next.next = pre.next; pre.next = next; } pre = cur; num -= k; } return dummy.next;}
阅读全文
0 0
- Rotate ListNode In K Groups
- 【leetcode】reverse Nodes in k-groups
- Reverse Nodes in K-Groups Leetcode Python
- ListNode
- Core-like groups result in invalidation of identifying super-spreader by k-shell
- Failure Groups in ASM
- 【java】遇到错误constructor ListNode in class ListNode cannot be applied to given types;
- [LeetCode] Swap Nodes in Pairs、Reverse Nodes in k-Group、Rotate List
- Users and Groups in Linux
- Activation Groups In AS/400
- 29、Failure Groups in ASM
- Familial groups in social networks
- LeetCode中几道链表反转相关题目(Reorder List、Rotate List、Reverse Nodes in k-Group)
- rotate object in matlab
- ListNode示例
- Groups
- groups
- Computer Vision Groups in the UK
- MongoDB数据建模小案例:多列数据结构
- 什么是CONTAINERD?
- 十大滤波算法总结
- 一台电脑同时运行两个tomcat
- java面试之HashMap延伸出来的--什么是ConcurrentHashMap?
- Rotate ListNode In K Groups
- MDK中软仿真下Debug-(printf)-Viewer的使用方法
- eclipse+Ant+testng+jenkins 持续集成环境的搭建
- UE4C++声明结构体和枚举体
- 参考PM通知单创建订单
- Python删除n行后的其他行
- HOG_SVM_行人检测数据集合_INRIA数据集
- 51nod 1244 莫比乌斯函数之和【杜教筛】
- 初次搭建ssm(springboot+springMvc+Mybatis)框架实践之路