当前位置:网站首页>Reverse linked list drawing demonstration
Reverse linked list drawing demonstration
2022-07-24 00:23:00 【T.Y.Bao】
subject
Here's the head node of the list head , Please reverse the list , And return the inverted linked list .
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int val) { this.val = val; } * ListNode(int val, ListNode next) { this.val = val; this.next = next; } * } */
class Solution {
public ListNode reverseList(ListNode head) {
}
}
Answer key
class Solution {
public ListNode reverseList(ListNode head) {
ListNode prev = null;
ListNode curr = head;
while (curr != null) {
ListNode next = curr.next;
curr.next = prev;
prev = curr;
curr = next;
}
return prev;
}
}
author :LeetCode-Solution
link :https://leetcode.cn/problems/reverse-linked-list/solution/fan-zhuan-lian-biao-by-leetcode-solution-d1k2/
source : Power button (LeetCode)
The copyright belongs to the author . Commercial reprint please contact the author for authorization , Non-commercial reprint please indicate the source .
Drawing demonstration

边栏推荐
- Gbase 8C string operator
- Summarize the plan, clarify the direction, concentrate and start a new situation -- the Counterpart Assistance Project of hexu software has achieved remarkable results
- 蓝绿部署、金丝雀发布、A/B测试是什么
- GBase 8c 访问权限访问函数(四)
- Redis持久化机制RDB、AOF
- Gbase 8C session information function (6)
- Sed in-depth understanding and use
- 二叉搜索树的简易实现及剖析
- Codeforces Round #807 (Div. 2)(A-D)
- Multi data source configuration of mongodb
猜你喜欢

Understanding polymorphism and letting different "people" do the same thing will produce different results

Don't let Fujin Yibo see this

mongodb的多数据源配置

【译】Go RPC 入门:Hello World

Multi knapsack explanation of dynamic programming knapsack problem

Inftnews | protect the "Snow Mountain Spirit", and the 42verse "digital ecological protection" public welfare project is about to start
![[translation] Introduction to go RPC: Hello World](/img/dd/7887f056bc031fe50253078dd355d0.png)
[translation] Introduction to go RPC: Hello World

PayPal subscription process and API request

Detectron2 installation based on Anaconda under win10
![[Android kotlin] property, getter and setter](/img/f7/a3b79e3f7c4396a240eb5749c450d3.png)
[Android kotlin] property, getter and setter
随机推荐
加密技术应用
English语法_指示代词 - So
【微信小程序】拍卖商品详情页设计与交互实现(包含倒计时、实时更新出价)
[wechat applet] design and interactive implementation of auction product details page (including countdown and real-time update of bids)
Nacos
Docker pulls the redis image and runs it
Gbase 8C access authority query function (I)
Gbase 8C session information function (V)
GBase 8c 会话信息函数(三)
Simple implementation and analysis of binary search tree
2022年7月23日——mapper文件说明
书写SQL必养成的好习惯
GBase 8c系统表信息函数(三)
数据模型设计方法概述
理解多态,让不同的“人”做同一件事情会产生不同的结果
[translation] Introduction to go RPC: Hello World
[low code] limitations of low code development
Automatic escape processing in JMeter
分布式之 CAP 原则
Material return on investment