当前位置:网站首页>Force buckle 92 Reverse linked list II
Force buckle 92 Reverse linked list II
2022-06-13 04:45:00 【Look at the mountains_ Lau】
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(int x, ListNode *next) : val(x), next(next) {}
* };
*/
class Solution {
public:
ListNode* reverseBetween(ListNode* head, int left, int right) {
if(left == right) return head;
auto ans = new ListNode(-1, head), ptr = ans;
for(int i = 0; i < left - 1; ++i)
ptr = ptr->next;
auto p1 = ptr->next;
for(int i = 0; i < right - left; ++i)
{
auto temp = p1->next;
p1->next= temp->next;
temp->next = ptr->next;
ptr->next = temp;
}
return ans->next;
}
};
边栏推荐
- php开发博客系统的首页头部功能实现
- 如何只用4步,实现一个自定义JDBC驱动?
- Webpack system learning (VIII) how contenthash can prevent browsers from using cache files
- 【Flutter 問題系列第 67 篇】在 Flutter 中使用 Get 插件在 Dialog 彈窗中不能二次跳轉路由問題的解决方案
- Avantages de win8.1 et win10
- 2022 ICLR | CONTRASTIVE LEARNING OF IMAGE- AND STRUCTURE BASED REPRESENTATIONS IN DRUG DISCOVERY
- Message scrolling JS implementation
- Crawler scrapy framework learning 2
- Recommended temporary online image compression tool
- On switch() case statement in C language
猜你喜欢

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

利用Javeswingjdbc基於mvc設計系統

力扣刷题338.比特位计数

How to use redis

利用Javeswingjdbc基于mvc设计系统

Several methods of identifying equivalent circuit of circuit drawing

Record a troubleshooting process - video call cannot be picked up

无限循环滚动代码阿里巴巴国际站店铺装修代码底图滚动黑色半透明显示效果自定义内容装修代码全屏显示
![[try to hack] upload labs (temporarily write to 12)](/img/df/dbb78121f7428e25ffb73cfc43ce1b.png)
[try to hack] upload labs (temporarily write to 12)

Powershell 加域 Add-Computer模块
随机推荐
How to handle async/await error messages gracefully
Basic syntax example for go
2022氯化工艺操作证考试题库及模拟考试
Latex operation
What is the difference between ROM, ram and flash? SRAM、DRAM、PROM、EPROM、EEPROM
The problem that ionic3 cannot automatically install the APK package
Cesium:cesiumlab makes image slices and loads slices
php 18 首页的文章列表功能实现
2022道路运输企业安全生产管理人员操作证考试题库及答案
Flutter dart variables and constants
PowerShell plus domain add computer module
【Flutter 问题系列第 67 篇】在 Flutter 中使用 Get 插件在 Dialog 弹窗中不能二次跳转路由问题的解决方案
【Flutter 問題系列第 67 篇】在 Flutter 中使用 Get 插件在 Dialog 彈窗中不能二次跳轉路由問題的解决方案
[LeetCode]-二分查找
Use service worker to preferentially request resources - continuous update
Conception d'un système basé sur MVC avec javaswing JDBC
Little C's Notepad
Crawler scrapy framework learning 1
[LeetCode]-滑动窗口
Applet version update