1.编辑器

我使用的是win10+vscode+leetcode+python3
环境配置参见我的博客:
链接

2.第一百六十题

(1)题目
英文:
Write a program to find the node at which the intersection of two singly linked lists begins.

For example, the following two linked lists:

中文:
编写一个程序,找到两个单链表相交的起始节点。

来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/intersection-of-two-linked-lists

(2)解法
使用双指针法,不管哪个指针先到一个list的尾部,都会从另个一list开头进行继续移动。
(耗时:176ms,内存:28.7M)

# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = Noneclass Solution:def getIntersectionNode(self, headA: ListNode, headB: ListNode) -> ListNode:p, q = headA, headBwhile p != q:if p:p = p.nextelse:p = headBif q:q = q.nextelse:q = headAreturn p

leetcode python3 简单题160. Intersection of Two Linked Lists相关推荐

  1. LeetCode(160): Intersection of Two Linked Lists

    Intersection of Two Linked Lists: Write a program to find the node at which the intersection of two ...

  2. leetcode python3 简单题225. Implement Stack using Queues

    1.编辑器 我使用的是win10+vscode+leetcode+python3 环境配置参见我的博客: 链接 2.第二百二十五题 (1)题目 英文: Implement the following ...

  3. leetcode python3 简单题70. Climbing Stairs

    1.编辑器 我使用的是win10+vscode+leetcode+python3 环境配置参见我的博客: 链接 2.第七十题 (1)题目 英文: You are climbing a stair ca ...

  4. leetcode python3 简单题69. Sqrt(x)

    1.编辑器 我使用的是win10+vscode+leetcode+python3 环境配置参见我的博客: 链接 2.第六十九题 (1)题目 英文: Implement int sqrt(int x). ...

  5. leetcode python3 简单题53. Maximum Subarray

    1.编辑器 我使用的是win10+vscode+leetcode+python3 环境配置参见我的博客: 链接 2.第五十三题 (1)题目 英文: Given an integer array num ...

  6. leetcode python3 简单题58. Length of Last Word

    1.编辑器 我使用的是win10+vscode+leetcode+python3 环境配置参见我的博客: 链接 2.第五十八题 (1)题目 英文: Given a string s consists ...

  7. leetcode python3 简单题14. Longest Common Prefix

    1.编辑器 我使用的是win10+vscode+leetcode+python3 环境配置参见我的博客: 链接 2.第十四题 (1)题目 英文: Write a function to find th ...

  8. leetcode python3 简单题234. Palindrome Linked List

    1.编辑器 我使用的是win10+vscode+leetcode+python3 环境配置参见我的博客: 链接 2.第二百三十四题 (1)题目 英文: Given a singly linked li ...

  9. leetcode python3 简单题232. Implement Queue using Stacks

    1.编辑器 我使用的是win10+vscode+leetcode+python3 环境配置参见我的博客: 链接 2.第二百三十二题 (1)题目 英文: Implement the following ...

最新文章

  1. svn命令行 批量添加(add)所有新增文件
  2. Eclipse 设置
  3. 华南理工大学网络教育计算机答案,计算机电路基础·随堂练习2019春华南理工大学网络教育答案.doc...
  4. python sklearn.preprocessing.standardScaler 的transform和fit_transform方法
  5. python直方图拟合曲线_在直方图python中拟合非标准化高斯
  6. nginx设置 二级域名 指定端口
  7. mysql 同一字段分别统计,mysql查询同一个字段根据不同值分组成不同列统计
  8. mysql 5.7 安装_MySQL 5.7 的安装历程
  9. mysql test run_MySQL自动测试框架
  10. c#开发环境下用Directx载入3D模型
  11. linux tftp 下载命令,Linux tftp命令
  12. # Day8:类的方法、三大特征、装饰器、组合、多态、设计模式
  13. 06-作业练习盒子模型
  14. Qlikview常用VB脚本
  15. 教大家写几个可能用得上的css3简单动画
  16. [bzoj1812][IOI2006]riv_多叉树转二叉树_树形dp
  17. ElasticSearch的基本操作第三章
  18. 折旧程序一直运行,无法停下怎么办?
  19. Echarts中国地图三级钻取
  20. 条码 vs RFID: 条码应用的优势

热门文章

  1. php球鞋,适合宽脚选手的球鞋有哪些“宽型脚”必备的实战利器推荐
  2. xercesimpl做什么用的_一体化泵站是用来做什么的有什么用
  3. python中面向对象空间时间_零基础老男孩学Python|面向对象之类的空间问题
  4. python做项目管理代码_代码发布项目(三)——python操作git、代码发布流程(服务器管理、项目管理)...
  5. mysql修改binlog 位置_查看mysql 的binlog日志存放的位置(转)
  6. 软件工程导论 09章面向对象方法学
  7. 中文信息处理—已分词标注语料的抽取词表和文本还原
  8. Python——(Anaconda+PyCharm)Youki的Python环境配置笔记(Windows版本)(legacy)~
  9. Ubuntu 16.04 用apt-get来安装Java
  10. C# Winform代码片段-大二下学期的垃圾代码