Leetcode-142. Linked List Cycle II
来源:互联网 发布:组织架构优化原则 编辑:程序博客网 时间:2024/06/16 19:31
前言:为了后续的实习面试,开始疯狂刷题,非常欢迎志同道合的朋友一起交流。因为时间比较紧张,目前的规划是先过一遍,写出能想到的最优算法,第二遍再考虑最优或者较优的方法。如有错误欢迎指正。博主首发CSDN,mcf171专栏。
博客链接:mcf171的博客
——————————————————————————————
Given a linked list, return the node where the cycle begins. If there is no cycle, return null
.
Note: Do not modify the linked list.
Follow up:
Can you solve it without using extra space?
public class Solution { public ListNode detectCycle(ListNode head) { Set<ListNode> set = new HashSet<ListNode>();ListNode node = null;while(head != null){if(set.contains(head)) {node = head;break;}else{set.add(head); head = head.next;}}return node; }}这个写的好不使用额外空间solve
0 0
- [LeetCode]141. Linked List Cycle【&142. Linked List Cycle II】
- leetcode--141. Linked List Cycle&&142. Linked List Cycle II
- LeetCode 141. Linked List Cycle && 142. Linked List Cycle II
- 142. Linked List Cycle II leetcode list
- LeetCode 142. Linked List Cycle II
- [LeetCode]142.Linked List Cycle II
- [leetcode] 142.Linked List Cycle II
- [leetcode] 142. Linked List Cycle II
- leetcode 142. Linked List Cycle II
- [Leetcode]142. Linked List Cycle II @python
- [LeetCode]142. Linked List Cycle II
- 142. Linked List Cycle II LeetCode
- LeetCode:142. Linked List Cycle II
- LeetCode--142. Linked List Cycle II
- LeetCode 142. Linked List Cycle II
- LeetCode 142. Linked List Cycle II
- LeetCode *** 142. Linked List Cycle II
- LeetCode 142. Linked List Cycle II
- 判断一个Activity是否处于栈顶
- Python默认参数的设计陷阱
- php ’Call to undefined function pcntl_fork‘
- 最全前端面试题
- 第九周项目三(矩阵转置)
- Leetcode-142. Linked List Cycle II
- CocosStudio(八)AtlasLabel数字标签、BitmapLabel自定义字体、Label文本框
- 偏函数functools.partial
- Android软键盘弹出时把布局顶上去的解决方法
- CSS 基础(022_图片画廊)
- edittext 显示问题
- ABAP选择表解析
- 开发Android Apps,我所努力学习到的三十多条宝贵经验
- mybatis查询sql中in条件使用(foreach)