当前位置:网站首页>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;
}
}
边栏推荐
- Reading notes of effective managers
- MFC 动态创建的对话框及改变控件的大小和位置
- The latest 2022 review of "graph classification research"
- D - How Many Answers Are Wrong
- Request forwarding and redirection
- 黑猫带你学UFS协议第8篇:UFS初始化详解(Boot Operation)
- D - How Many Answers Are Wrong
- 多线程应用的测试与调试
- 【Postman】测试(Tests)脚本编写和断言详解
- LeetCode 732. 我的日程安排表 III
猜你喜欢
![[eolink] PC client installation](/img/91/8b3c4264e544b14f926e91edddf18d.png)
[eolink] PC client installation

Nodejs realizes the third-party login of Weibo
![[postman] collections configuration running process](/img/09/bcd9fd6379fa724671ffd09278442e.png)
[postman] collections configuration running process
![[postman] test script writing and assertion details](/img/65/6520fe78bb2b3ff99f16d09ea8c0d1.png)
[postman] test script writing and assertion details

黑猫带你学UFS协议第4篇:UFS协议栈详解

数字三角形模型 AcWing 1015. 摘花生

MFC关于长字符串unsigned char与CString转换及显示问题

MySQL之基础知识
![Buuctf-[gxyctf2019] no dolls (xiaoyute detailed explanation)](/img/0a/054b994b29d4c50ede8b23514cf4ee.jpg)
Buuctf-[gxyctf2019] no dolls (xiaoyute detailed explanation)
![[postman] collections - run the imported data file of the configuration](/img/85/7ac9976fb09c465c88f376b2446517.png)
[postman] collections - run the imported data file of the configuration
随机推荐
Coordinatorlayout+nestedscrollview+recyclerview pull up the bottom display is incomplete
[postman] collections configuration running process
[postman] dynamic variable (also known as mock function)
技术分享 | 常见接口协议解析
联合索引的左匹配原则
Function of activation function
GTSAM中李群的運用
LeetCode 739. 每日温度
Eigen sparse matrix operation
浅谈专项测试之弱网络测试
黑猫带你学UFS协议第4篇:UFS协议栈详解
模拟卷Leetcode【普通】1314. 矩阵区域和
win10无法操作(删除、剪切)文件
一文揭开,测试外包公司的真 相
数学三大核心领域概述:几何
把el-tree选中的数组转换为数组对象
On weak network test of special test
[leetcode] day96 - the first unique character & ransom letter & letter ectopic word
曼哈顿距离与曼哈顿矩形-打印回字型矩阵
G - Supermarket