(Java) LeetCode 25. Reverse Nodes in k-Group —— k个一组翻转链表

Posted 小T在学习

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了(Java) LeetCode 25. Reverse Nodes in k-Group —— k个一组翻转链表相关的知识,希望对你有一定的参考价值。

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.

k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.

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 

Note:

  • Only constant extra memory is allowed.
  • You may not alter the values in the list‘s nodes, only nodes itself may be changed.

 


 

以上是关于(Java) LeetCode 25. Reverse Nodes in k-Group —— k个一组翻转链表的主要内容,如果未能解决你的问题,请参考以下文章

我用java刷 leetcode 剑指 Offer 25. 合并两个排序的链表

LeetCode - 25. K 个一组翻转链表 -- java - 细节

LeetCode Java刷题笔记—25. K 个一组翻转链表

(Java) LeetCode 25. Reverse Nodes in k-Group —— k个一组翻转链表

精选力扣500题 第25题 LeetCode 54. 螺旋矩阵c++ / java 详细题解

小Y学算法⚡️每日LeetCode打卡⚡️——25.二叉树的中序遍历