剑指offer 16 反转链表
来源:互联网 发布:双系统ubuntu安装教程 编辑:程序博客网 时间:2024/05/19 12:27
题目描述
输入一个链表,反转链表后,输出链表的所有元素。
思路:
从头到尾遍历,把每个结点反向指过来。
# -*- coding:utf-8 -*-# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Solution: # 返回ListNode def ReverseList(self, pHead): # write code here if pHead == None: return None pTail = None res = None while pHead != None: pNext = pHead.next if pNext == None: res = pHead pHead.next = pTail pTail = pHead pHead = pNext return res
阅读全文
0 0
- 剑指offer 16- 反转链表
- 16链表的反转|剑指offer
- 剑指Offer 16 反转链表
- 剑指offer-16:反转链表
- 【剑指offer】题16:反转链表
- 剑指offer面试16 反转链表
- 剑指offer 16 反转链表
- 剑指offer:反转链表
- 剑指offer--反转链表
- 剑指offer--反转链表
- 剑指Offer-反转链表
- 《剑指offer》反转链表
- 剑指 offer:反转链表
- 剑指offer-反转链表
- 剑指offer 反转链表
- 剑指offer-反转链表
- 剑指offer:反转链表
- [剑指offer]反转链表
- Android6.0权限,如何封装处理授权问题
- xgboost安装教程,可用
- Win10使用SublimeText3代替Arduino IDE开发Arduino程序
- 东野圭吾《梦幻花》读后感
- 云数据库MongoDB版使用教程
- 剑指offer 16 反转链表
- 如何看待机器视觉的“对抗样本”问题,其原理是什么?
- IOS学习 Sqlite索引
- ie8兼容问题(二) select文字垂直居中问题
- JAVA读取Excel任何格式的内容
- Android Studio创建Android公共库模块
- 阿里云linux服务器下安装node.js
- numpy函数记录
- JS 事件循环机制