当前位置:网站首页>leetcode 24. Exchange the nodes in the linked list in pairs
leetcode 24. Exchange the nodes in the linked list in pairs
2022-07-06 06:18:00 【henujolly】
class Solution {
public ListNode swapPairs(ListNode head) {
ListNode dummyHead = new ListNode();
dummyHead.next = head;
ListNode temp = dummyHead;
while (temp.next != null && temp.next.next != null) {
ListNode node1 = temp.next;
ListNode node2 = temp.next.next;
temp.next = node2;
node1.next = node2.next;
node2.next = node1;
temp = node1;
}
return dummyHead.next;
}
}
边栏推荐
- Buuctf-[bjdctf2020]zjctf, but so (xiaoyute detailed explanation)
- Application of Lie group in gtsam
- selenium源码通读·9 |DesiredCapabilities类分析
- 10m25dcf484c8g (FPGA) amy-6m-0002 BGA GPS module
- 异常检测方法总结
- LeetCode 732. 我的日程安排表 III
- 模拟卷Leetcode【普通】1109. 航班预订统计
- Postman核心功能解析-参数化和测试报告
- An article was uncovered to test the truth of outsourcing companies
- Cannot create PoolableConnectionFactory (Could not create connection to database server. 错误
猜你喜欢
![Buuctf-[[gwctf 2019] I have a database (xiaoyute detailed explanation)](/img/2c/43ce298794589c5282edda94161d62.jpg)
Buuctf-[[gwctf 2019] I have a database (xiaoyute detailed explanation)

MySQL之数据类型
![[postman] test script writing and assertion details](/img/65/6520fe78bb2b3ff99f16d09ea8c0d1.png)
[postman] test script writing and assertion details

Manage configuration using Nacos

数据库-当前读与快照读

Significance of unit testing

【Postman】Monitors 监测API可定时周期运行

曼哈顿距离和-打印菱形

Digital triangle model acwing 1015 Picking flowers

keil MDK中删除添加到watch1中的变量
随机推荐
keil MDK中删除添加到watch1中的变量
Database - current read and snapshot read
Coordinatorlayout+nestedscrollview+recyclerview pull up the bottom display is incomplete
【Postman】Monitors 监测API可定时周期运行
全链路压测:构建三大模型
数学三大核心领域概述:代数
把el-tree选中的数组转换为数组对象
Leaflet map
Summary of anomaly detection methods
[postman] the monitors monitoring API can run periodically
LeetCode 731. 我的日程安排表 II
异常检测方法总结
Win10 cannot operate (delete, cut) files
对数据安全的思考(转载)
Manage configuration using Nacos
模拟卷Leetcode【普通】1218. 最长定差子序列
Pat (Grade B) 2022 summer exam
Caused by:org. gradle. api. internal. plugins . PluginApplicationException: Failed to apply plugin
【C语言】qsort函数
联合索引的左匹配原则