当前位置:网站首页>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;
}
}
边栏推荐
- Hypothesis testing learning notes
- 【无App Push 通用测试方案
- G - Supermarket
- 模拟卷Leetcode【普通】1405. 最长快乐字符串
- D - How Many Answers Are Wrong
- Expose the serial fraudster Liu Qing in the currency circle, and default hundreds of millions of Cheng Laolai
- Redis 核心技术与实战之 基本架构:一个键值数据库包含什么?
- IP day 16 VLAN MPLS configuration
- [postman] test script writing and assertion details
- Caused by:org.gradle.api.internal.plugins . PluginApplicationException: Failed to apply plugin
猜你喜欢
Detailed explanation of P problem, NP problem, NPC problem and NP hard problem
On weak network test of special test
[ram IP] introduction and experiment of ram IP core
[postman] collections - run the imported data file of the configuration
数学三大核心领域概述:代数
MySQL之基础知识
GTSAM中李群的运用
Full link voltage measurement: building three models
10M25DCF484C8G(FPGA) AMY-6M-0002 BGA GPS模块
【C语言】字符串左旋
随机推荐
Simulation volume leetcode [general] 1109 Flight reservation statistics
Eigen sparse matrix operation
还在为如何编写Web自动化测试用例而烦恼嘛?资深测试工程师手把手教你Selenium 测试用例编写
LeetCode 739. 每日温度
Seven imperceptible truths in software testing
调用链监控Zipkin、sleuth搭建与整合
MFC 动态创建的对话框及改变控件的大小和位置
LeetCode 1200. 最小绝对差
Application of Lie group in gtsam
Win10 cannot operate (delete, cut) files
Function of activation function
ESP32 ESP-IDF看门狗TWDT
[postman] collections configuration running process
Understanding of processes and threads
Linux regularly backs up MySQL database
[wechat applet] build a development tool environment
win10无法操作(删除、剪切)文件
模拟卷Leetcode【普通】1091. 二进制矩阵中的最短路径
一文揭开,测试外包公司的真 相
使用Nacos管理配置