当前位置:网站首页>leetcode 24. Exchange the nodes in the linked list in pairs
leetcode 24. Exchange the nodes in the linked list in pairs
2022-07-06 06:18: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;
}
}
边栏推荐
- GTSAM中李群的运用
- Web界面元素的测试
- LeetCode 1200. 最小绝对差
- 曼哈顿距离与曼哈顿矩形-打印回字型矩阵
- Selenium source code read through · 9 | desiredcapabilities class analysis
- ICLR 2022 spotlight | analog transformer: time series anomaly detection method based on correlation difference
- Overview of three core areas of Mathematics: geometry
- keil MDK中删除添加到watch1中的变量
- Online and offline problems
- 联合索引的左匹配原则
猜你喜欢

properties文件
![[wechat applet] build a development tool environment](/img/f6/51f97b1c927337b34c5b3a4207abb4.png)
[wechat applet] build a development tool environment

【eolink】PC客户端安装

IP day 16 VLAN MPLS configuration

【Postman】Collections-运行配置之导入数据文件
![[C language] string left rotation](/img/5f/66bcc8f992108bf3b7e455709d3174.png)
[C language] string left rotation

自定义指定路由上的Gateway过滤器工厂

进程和线程的理解

ESP32 ESP-IDF看门狗TWDT

Expose the serial fraudster Liu Qing in the currency circle, and default hundreds of millions of Cheng Laolai
随机推荐
还在为如何编写Web自动化测试用例而烦恼嘛?资深测试工程师手把手教你Selenium 测试用例编写
G - Supermarket
Resttemplate and feign realize token transmission
[postman] collections - run the imported data file of the configuration
Simulation volume leetcode [general] 1062 Longest repeating substring
leetcode 24. 两两交换链表中的节点
通过修改style设置打印页样式
Thoughts on data security (Reprint)
[no app push general test plan
【API接口工具】postman-界面使用介绍
【eolink】PC客户端安装
Reading notes of effective managers
GTSAM中李群的運用
进程和线程的理解
Leaflet map
keil MDK中删除添加到watch1中的变量
MFC关于长字符串unsigned char与CString转换及显示问题
Interface test: what are the components of the URL in fiddler
Caused by:org. gradle. api. internal. plugins . PluginApplicationException: Failed to apply plugin
How to extract login cookies when JMeter performs interface testing