当前位置:网站首页>leetcode 24. 两两交换链表中的节点
leetcode 24. 两两交换链表中的节点
2022-07-06 06:15: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;
}
}
边栏推荐
- 数学三大核心领域概述:几何
- Still worrying about how to write web automation test cases? Senior test engineers teach you selenium test case writing hand in hand
- win10无法操作(删除、剪切)文件
- 全程实现单点登录功能和请求被取消报错“cancelToken“ of undefined的解决方法
- PAT(乙级)2022年夏季考试
- D - How Many Answers Are Wrong
- 把el-tree选中的数组转换为数组对象
- leaflet 地图
- Postman核心功能解析-参数化和测试报告
- 全链路压测:构建三大模型
猜你喜欢

Significance of unit testing

Manage configuration using Nacos

曼哈顿距离和-打印菱形

Properties file

Manhattan distance sum - print diamond

曼哈顿距离与曼哈顿矩形-打印回字型矩阵

The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower

MySQL之数据类型

Digital triangle model acwing 1015 Picking flowers

IDEA 新UI使用
随机推荐
Function of contenttype
Still worrying about how to write web automation test cases? Senior test engineers teach you selenium test case writing hand in hand
【C语言】qsort函数
ESP32 ESP-IDF看门狗TWDT
Leaflet map
Expose the serial fraudster Liu Qing in the currency circle, and default hundreds of millions of Cheng Laolai
调用链监控Zipkin、sleuth搭建与整合
Application of Lie group in gtsam
D - How Many Answers Are Wrong
Usage of test macro of GTEST
全链路压测:构建三大模型
IP day 16 VLAN MPLS configuration
Fault, error, failure of functional safety
[eolink] PC client installation
模拟卷Leetcode【普通】1447. 最简分数
Postman核心功能解析-参数化和测试报告
Coordinatorlayout+nestedscrollview+recyclerview pull up the bottom display is incomplete
数学三大核心领域概述:几何
技术分享 | 常见接口协议解析
P问题、NP问题、NPC问题、NP-hard问题详解