当前位置:网站首页>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 cannot operate (delete, cut) files
- Detailed explanation of P problem, NP problem, NPC problem and NP hard problem
- ICLR 2022 spotlight | analog transformer: time series anomaly detection method based on correlation difference
- B - The Suspects
- PAT(乙级)2022年夏季考试
- 误差的基本知识
- 黑猫带你学UFS协议第4篇:UFS协议栈详解
- 数据库隔离级别
- Function of activation function
- CoordinatorLayout+NestedScrollView+RecyclerView 上拉底部显示不全
猜你喜欢
![[C language] string left rotation](/img/5f/66bcc8f992108bf3b7e455709d3174.png)
[C language] string left rotation

Summary of anomaly detection methods

异常检测方法总结
![[postman] collections - run the imported data file of the configuration](/img/85/7ac9976fb09c465c88f376b2446517.png)
[postman] collections - run the imported data file of the configuration

LeetCode 739. 每日温度

E - food chain

What are the test sites for tunnel engineering?

GTSAM中李群的運用

Left matching principle of joint index

IP day 16 VLAN MPLS configuration
随机推荐
2022 software testing workflow to know
Summary of anomaly detection methods
黑猫带你学UFS协议第8篇:UFS初始化详解(Boot Operation)
Isam2 operation process
B - The Suspects
LeetCode 1200. 最小绝对差
Customize the gateway filter factory on the specified route
Still worrying about how to write web automation test cases? Senior test engineers teach you selenium test case writing hand in hand
sourceInsight中文乱码
ICLR 2022 spotlight | analog transformer: time series anomaly detection method based on correlation difference
Thoughts on data security (Reprint)
Buuctf-[[gwctf 2019] I have a database (xiaoyute detailed explanation)
单元测试的意义
Overview of three core areas of Mathematics: algebra
isam2运行流程
MFC 动态创建的对话框及改变控件的大小和位置
【微信小程序】搭建开发工具环境
【Postman】动态变量(也称Mock函数)
黑猫带你学eMMC协议第10篇:eMMC读写操作详解(read & write)
Amazon Engineer: eight important experiences I learned in my career