当前位置:网站首页>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;
}
}
边栏推荐
猜你喜欢
Construction and integration of Zipkin and sleuth for call chain monitoring
PAT(乙级)2022年夏季考试
JWT-JSON WEB TOKEN
【Postman】Collections配置运行过程
Buuctf-[[gwctf 2019] I have a database (xiaoyute detailed explanation)
LeetCode 1200. 最小绝对差
Detailed explanation of P problem, NP problem, NPC problem and NP hard problem
职场进阶指南:大厂人必看书籍推荐
10m25dcf484c8g (FPGA) amy-6m-0002 BGA GPS module
JMeter做接口测试,如何提取登录Cookie
随机推荐
曼哈顿距离和-打印菱形
Basic knowledge of error
Isam2 and incrementalfixedlagsmooth instructions in gtsam
[ram IP] introduction and experiment of ram IP core
Fault, error, failure of functional safety
Hypothesis testing learning notes
selenium源码通读·9 |DesiredCapabilities类分析
On weak network test of special test
Function of activation function
Application of Lie group in gtsam
进程和线程的理解
Usage of test macro of GTEST
Nodejs realizes the third-party login of Weibo
Caused by:org. gradle. api. internal. plugins . PluginApplicationException: Failed to apply plugin
Request forwarding and redirection
还在为如何编写Web自动化测试用例而烦恼嘛?资深测试工程师手把手教你Selenium 测试用例编写
通过修改style设置打印页样式
MySQL之基础知识
Manage configuration using Nacos
使用Nacos管理配置