题目描述

leetcode25. K个一组翻转链表

 思路:递归

以链表1->2->3->4->5为例,K=2

1)将链表划分为两个链表,一个包含前K个节点,一个包含剩下的节点,即1->2和3->4->5两个链表。

2)对链表1->2进行整体翻转;对链表2-3->4递归进行K个一组翻转。

leetcode25. K个一组翻转链表

leetcode25. K个一组翻转链表 

题目来源:https://leetcode-cn.com/problems/reverse-nodes-in-k-group/

相关文章:

  • 2022-12-23
  • 2021-07-19
  • 2021-09-12
  • 2021-08-31
  • 2021-09-17
  • 2022-12-23
  • 2021-10-09
猜你喜欢
  • 2021-05-01
  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-07
相关资源
相似解决方案