当前位置:网站首页>Leetcode-92-reverse linked list
Leetcode-92-reverse linked list
2022-04-22 20:45:00 【Own platform 9 and 3 / 4】
1. Problem description
https://leetcode-cn.com/problems/reverse-linked-list-ii/
- Solution code
public class Solution {
public ListNode ReverseBetween(ListNode head, int left, int right) {
// Set up dummyNode It's the general approach to this kind of problem
ListNode dummyNode = new ListNode(-1);
dummyNode.next = head;
ListNode pre = dummyNode;
for (int i = 0; i < left - 1; i++) {
pre = pre.next;
}
ListNode cur = pre.next;
ListNode next;
for (int i = 0; i < right - left; i++) {
next = cur.next;
cur.next = next.next;
next.next = pre.next;
pre.next = next;
}
return dummyNode.next;
}
}
版权声明
本文为[Own platform 9 and 3 / 4]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204222044174696.html
边栏推荐
- 分库分表&百亿级数据迁移
- [ DASCTF Oct X ]迷路的魔法少女
- 字符数组与字符串:删除字符串所有空格。 (10 分)编写一个函数,用来删除字符串中的所有空格。
- 动态数据库工具——Database Inspector
- 面试官宁愿要刚刚毕业工作1年的我小弟,也不要工作5年的我,年薪25w
- Dynamic database tool -- database inspector
- Chapter 2 array
- Xshell7、Xftp7、Xlpd7-下载与安装教程(亲测可用)
- MySQL storage engine
- The list of SCI / SSCI journals has been updated and these journals have been eliminated~
猜你喜欢

2022年土建施工员题库精准小题库建设厅施工员

Markdown learning and Practice

故障分析 | Federated 存储引擎表导致监控线程处于 Opening table 状态

木瓜移动课堂:产品更新,Facebook新增素材预审功能,力控广告违规~

List的使用

打造新一代计算平台,STEPVR将在2022开启元宇宙“大门”

Add / remove / filter / sort array elements

LeeCode 130. 被围绕的区域

Ziguang Guowei: it is actively expanding the category of analog chips, and some products have been sold in batches

MySQL主从复制之GTID复制
随机推荐
华为机试题——HJ72 百钱买百鸡问题
Better implementation ideas based on MySQL in some scenarios (continuous update)
MySQL storage engine
如何让机器人更像“人”,让slam更灵活?
Fault analysis | federated storage engine table causes the monitoring thread to be in the opening table state
转载:程序员的发展方向
Postman tests the correct posture of array, list and map input APIs
MySQL troubleshooting information query (continuous update)
字符串 - 7. 输出字符串 (10 分)C语言标准函数库中 printf 函数和 puts 函数都可以输出字符串,但各有优点和缺点。我们综合两者的优点,设计一个函数来输出字符串。
【youcans 的 OpenCV 例程200篇】160. 图像处理之OTSU 方法
A thorough explanation of the future form, development status and Prospect of Business Intelligence BI | recommended collection
CmsEasy7.6.3.2逻辑漏洞
[interview ordinary people vs Expert Series] please talk about the network quadruple
Some considerations for pointers and objects
2022 civil construction worker's question bank precision small question bank construction hall constructor
Timestamp conversion
年薪170W阿里P8相亲要求女方月薪1万,网友:有点高
What is a SAML assertion?
buuctf-[Flask]SSTI
(l2-026) small generation (with weight and search set)