当前位置:网站首页>Power button 206 - reverse list - the list
Power button 206 - reverse list - the list
2022-08-03 20:12:00 【Zhang Ran Ran √】
Title description
Give you the head node of the singly linked list head, please reverse the linked list and return the reversed linked list.
Solution ideas
This is a simple question about linked lists, examining the inversion of linked lists;
We consider changing the point of the pointer, no need to create a new linked list;
Leverage a picture from Karge:

Input and output example


Code
/*** 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) {ListNode pre = null;ListNode tem = null;ListNode cur = head;while(cur != null){tem = cur.next;cur.next = pre;pre = cur;cur = item;}return pre;}}边栏推荐
猜你喜欢
[email protected] 594/[email prote"/>RNA核糖核酸修饰Alexa 568/[email protected] 594/[email prote

Li Mu hands-on learning deep learning V2-BERT fine-tuning and code implementation

async 和 await 原来这么简单

高并发,你真的理解透彻了吗?

RNA-ATTO 390|RNA-ATTO 425|RNA-ATTO 465|RNA-ATTO 488|RNA-ATTO 495|RNA-ATTO 520近红外荧光染料标记核糖核酸RNA

Advantages and Disadvantages of Blind and Buried Via PCB Stacked Via Design

Go语言类型与接口的关系

使用 ReportLab 绘制 PDF

NNLM、RNNLM等语言模型 实现 下一单词预测(next-word prediction)

Why BI software can't handle correlation analysis
随机推荐
2022 CCF中国开源大会会议通知(第三轮)
RNA-ATTO 390|RNA-ATTO 425|RNA-ATTO 465|RNA-ATTO 488|RNA-ATTO 495|RNA-ATTO 520近红外荧光染料标记核糖核酸RNA
Kubernetes资源编排系列之三: Kustomize篇 作者 艄公(杨京华) 雪尧(郭耀星)
leetcode 2119. 反转两次的数字
Anaconda virtual environment migration
The sword refers to Offer II 044. The maximum value of each level of the binary tree-dfs method
ESP8266-Arduino编程实例-MCP4725数模转换器驱动
leetcode 461. 汉明距离
leetcode 16. 数值的整数次方(快速幂+递归/迭代)
第三方验收测试报告有什么作用?如何获取权威软件测试报告?
Go语言为任意类型添加方法
leetcode 899. 有序队列
Node version switching tool NVM and npm source manager nrm
leetcode 268. 丢失的数字(异或!!)
EasyCVR平台海康摄像头语音对讲功能配置的3个注意事项
Detailed demonstration pytorch framework implementations old photo repair (GPU)
李沐动手学深度学习V2-自然语言推断与数据集SNLI和代码实现
力扣707-设计链表——链表
leetcode 剑指 Offer 15. 二进制中1的个数
tRNA修饰2-甲基胞嘧啶(m2C)|tRNA修饰m2G (N2-methylguanosine)