LeetCode:Reverse Nodes in k-Group
1、题目名称 Reverse Nodes in k-Group(分组翻转链表) 2、题目地址 https://leetcode.com/problems/reverse-nodes-in-k-group 3、题目内容 英文: 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. 中文: 给出一个链表,以k个元素为一组,对各组内元素进行翻转。忽略最后不够k的元素的部分。可以只对节点中的值进行交换,空间复杂度须控制在O(1)。 举例: 给出链表:1->2->3->4->5 当 k = 2 时,翻转后的链表为:2->1->4->3->5 当 k = 3 时,翻转后的链表为:3->2->1->4->5 4、解题方法 对这个问题