当前位置:网站首页>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;}}
边栏推荐
猜你喜欢
不知道这4种缓存模式,敢说懂缓存吗?
Edge box + time series database, technology selection behind Midea's digital platform iBuilding
利用 rpush 和 blpop 实现 Redis 消息队列
高位套牢机构,用友网络的信任危机是如何产生的?
Matlab paper illustration drawing template No. 42 - bubble matrix diagram (correlation coefficient matrix diagram)
YARN功能介绍、交互流程及调度策略
单调栈及其应用
华为设备配置VRRP负载分担
[email protected] 610/[email protected] 594/Alexa 56"/>
染料修饰核酸RNA|[email protected] 610/[email protected] 594/Alexa 56
调用EasyCVR云台控制接口时,因网络延迟导致云台操作异常该如何解决?
随机推荐
使用 ReportLab 绘制 PDF
2022 年值得尝试的 7 个 MQTT 客户端工具
Anaconda virtual environment migration
宁德时代2号人物黄世霖辞任副董事长:身价1370亿
149. The largest number on a straight line, and check the set
C51 存储类型与存储模式
Golang死信队列的使用
tRNA修饰2-甲基胞嘧啶(m2C)|tRNA修饰m2G (N2-methylguanosine)
2022.8.2
微导纳米IPO过会:年营收4.28亿 君联与高瓴是股东
MapReduce介绍及执行过程
ES6解构赋值--数组解构及对象解构
Kubernetes资源编排系列之三: Kustomize篇 作者 艄公(杨京华) 雪尧(郭耀星)
力扣707-设计链表——链表
染料修饰核酸RNA|[email protected] 610/[email protected] 594/Alexa 56
tRNA-m5C转运RNA(tRNA)修饰5-甲基胞嘧啶(m5C)|tRNA修饰m1Am2A (2-methyladenosine)
软件测试基本流程有哪些?权威的第三方软件检测机构推荐
Matlab paper illustration drawing template No. 42 - bubble matrix diagram (correlation coefficient matrix diagram)
危化企业双重预防机制数字化建设进入全面实施阶段
花 30 美金请 AI 画家弄了个 logo,网友:画得非常好,下次别画了!