leetcode 25:Reverse Nodes in k-Group
2015-06-15 20:16
751 查看
k个节点为一组反转
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.
If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.
You may not alter the values in the nodes, only nodes itself may be changed.
Only constant memory is allowed.
For example,
Given this linked list:
For k = 2, you should return:
For k = 3, you should return:
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.
If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.
You may not alter the values in the nodes, only nodes itself may be changed.
Only constant memory is allowed.
For example,
Given this linked list:
1->2->3->4->5
For k = 2, you should return:
2->1->4->3->5
For k = 3, you should return:
3->2->1->4->5
相关文章推荐
- Remove Nth Node From End of List
- leetcode -Swap Nodes in Pairs
- Node.js学习--基础知识(6)--常用工具util和事件EventEmitter
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Java for LeetCode 222 Count Complete Tree Nodes
- Reverse Nodes in k-Group
- Node.js学习
- Node.js学习--基础知识(8)--全局对象和全局变量
- Hadoop 2.0 NameNode HA和Federation实践
- 【转】nodejs 模块加载
- Node.js学习--基础知识(5)--npm
- nodejs 中压缩/解压方案
- Angular Material串串学客户端开发 2 - Node.js模块加载机制Require()
- node.js 初体验
- Node.js+Yeoman构建前端自动化Web应用
- HDU 4587 Two Nodes、POJ 2375 Reliable Nets (Tarjan)
- Clone Graph Leetcode 133
- DOM Nodes
- leetcode--Populating Next Right Pointers in Each Node