当前位置:网站首页>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;
}
}
边栏推荐
- win10无法操作(删除、剪切)文件
- Application of Lie group in gtsam
- php使用redis实现分布式锁
- [postman] test script writing and assertion details
- [eolink] PC client installation
- MySQL之基础知识
- CoordinatorLayout+NestedScrollView+RecyclerView 上拉底部显示不全
- 模拟卷Leetcode【普通】1314. 矩阵区域和
- Isam2 and incrementalfixedlagsmooth instructions in gtsam
- Function of activation function
猜你喜欢
随机推荐
JWT-JSON WEB TOKEN
Buuctf-[[gwctf 2019] I have a database (xiaoyute detailed explanation)
还在为如何编写Web自动化测试用例而烦恼嘛?资深测试工程师手把手教你Selenium 测试用例编写
LeetCode 1200. 最小绝对差
RestTemplate、Feign实现Token传递
功能安全之故障(fault),错误(error),失效(failure)
[C language] string left rotation
Eigen sparse matrix operation
D - How Many Answers Are Wrong
Function of contenttype
模拟卷Leetcode【普通】1143. 最长公共子序列
Embedded point test of app
《卓有成效的管理者》读书笔记
JDBC Requset 对应内容及功能介绍
Isam2 operation process
[web security] nodejs prototype chain pollution analysis
Career advancement Guide: recommended books for people in big factories
[C language] qsort function
B - The Suspects
[postman] collections - run the imported data file of the configuration