当前位置:网站首页>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;
}
}
边栏推荐
- 全程实现单点登录功能和请求被取消报错“cancelToken“ of undefined的解决方法
- Detailed explanation of P problem, NP problem, NPC problem and NP hard problem
- 异常检测方法总结
- Buuctf-[gxyctf2019] no dolls (xiaoyute detailed explanation)
- P问题、NP问题、NPC问题、NP-hard问题详解
- 【Postman】Collections配置运行过程
- Overview of three core areas of Mathematics: algebra
- 浅谈专项测试之弱网络测试
- IDEA 新UI使用
- selenium源码通读·9 |DesiredCapabilities类分析
猜你喜欢

VINS-Mono: A Robust and Versatile Monocular Visual-Inertial State Estimator

数学三大核心领域概述:代数

GTSAM中李群的运用

On weak network test of special test
![[wechat applet] build a development tool environment](/img/f6/51f97b1c927337b34c5b3a4207abb4.png)
[wechat applet] build a development tool environment

Manhattan distance and Manhattan rectangle - print back font matrix

B - The Suspects

【Postman】测试(Tests)脚本编写和断言详解

全程实现单点登录功能和请求被取消报错“cancelToken“ of undefined的解决方法

Function of contenttype
随机推荐
Understanding of processes and threads
Detailed explanation of P problem, NP problem, NPC problem and NP hard problem
RestTemplate、Feign实现Token传递
Buuctf-[gxyctf2019] no dolls (xiaoyute detailed explanation)
Reading notes of effective managers
Expose the serial fraudster Liu Qing in the currency circle, and default hundreds of millions of Cheng Laolai
调用链监控Zipkin、sleuth搭建与整合
F - true liars (category and search set +dp)
JDBC Requset 对应内容及功能介绍
联合索引的左匹配原则
[leetcode] day96 - the first unique character & ransom letter & letter ectopic word
Pat (Grade B) 2022 summer exam
【Postman】动态变量(也称Mock函数)
Career advancement Guide: recommended books for people in big factories
模拟卷Leetcode【普通】1218. 最长定差子序列
进程和线程的理解
MySQL之数据类型
[C language] string left rotation
对数据安全的思考(转载)
Hypothesis testing learning notes