当前位置:网站首页>Force buckle 25 A group of K flipped linked lists
Force buckle 25 A group of K flipped linked lists
2022-06-13 04:45:00 【Look at the mountains_ Lau】
class Solution {
public:
ListNode* reverseKGroup(ListNode* head, int k) {
if (head == nullptr) return head;
auto tail = head;
for(int i = 0; i < k; ++i) // First, let tail Move k Nodes
{
if(tail == nullptr) return head; // Insufficient k Time
tail = tail->next;
}
ListNode* cur = head, *pre = nullptr, *next = nullptr;
while(cur != tail) // Be careful : reverse[head, tail)
{
next = cur->next;
cur->next = pre;
pre = cur;
cur = next;
}
head->next = reverseKGroup(tail, k); //@ In this group ,head Became the last node , Note the use of recursion (tail, k)
return pre; //@ Return to the flipped head node
}
};
边栏推荐
- 用navicat将mysql数据转化为postgresql
- Sword finger offer 56 - I. number of occurrences in the array
- PowerShell: because running scripts is prohibited on this system, the solution
- Recommended temporary online image compression tool
- 力扣刷题647.回文子串
- Applet waterfall flow
- CTFSHOW SQL注入篇(211-230)
- Uni app Ali font icon does not display
- Analysis of scoped attribute principle and depth action selector
- Flutter dart variables and constants
猜你喜欢

力扣刷题647.回文子串

Several methods of identifying equivalent circuit of circuit drawing

How to use redis

Optocoupler working principle function electric parameter application circuit

如何只用4步,实现一个自定义JDBC驱动?

PowerShell:因为在此系统上禁止运行脚本,解决方法

2022 ICLR | CONTRASTIVE LEARNING OF IMAGE- AND STRUCTURE BASED REPRESENTATIONS IN DRUG DISCOVERY
![[flutter problem Series Chapter 67] the Solution to the problem of Routing cannot be jumped again in in dialog popup Using get plug - in in flutter](/img/59/0d95619ee3bba1f8992d90267d45c2.png)
[flutter problem Series Chapter 67] the Solution to the problem of Routing cannot be jumped again in in dialog popup Using get plug - in in flutter

How to implement a custom jdbc driver in only four steps?

2022 ICML | Pocket2Mol: Efficient Molecular Sampling Based on 3D Protein Pockets
随机推荐
CreateAnonymousThreadX给匿名线程传递参数
2022 oxidation process operation certificate examination question bank and simulation examination
是“凯撒密码”呀。(*‘▽‘*)*
如何优雅的处理async/await错误信息
2022年氧化工艺操作证考试题库及模拟考试
Internet people a few years ago vs Internet people today
The processing flow of thread pool depends on the core parameters
Kaggle 时间序列教程
Basic syntax example for go
力扣刷题338.比特位计数
2022 ICML | Pocket2Mol: Efficient Molecular Sampling Based on 3D Protein Pockets
H5 the blue background color appears when clicking the picture
promise处理js多线程全部获得结果后同一处理结果
[untitled]
【Flutter 问题系列第 67 篇】在 Flutter 中使用 Get 插件在 Dialog 弹窗中不能二次跳转路由问题的解决方案
一致性哈希的简单认识
Normal distribution (Gaussian distribution)
PHP security development 15 user password modification module
Tita performance treasure: remote one-on-one discussion
Blockly learning ----1 Work area, block, toolbox