leetcode 日经贴,Cpp code -Linked List Cycle
来源:互联网 发布:最好的网络监控软件 编辑:程序博客网 时间:2024/06/03 13:01
Linked List Cycle
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: bool hasCycle(ListNode *head) { if (!head || !head->next) { return false; } ListNode *p1 = head, *p2 = head->next; while (p1 != p2 && p2) { p1 = p1->next; if (p2->next) { p2 = p2->next->next; } else { p2 = p2->next; } } return p1 == p2; }};
0 0
- leetcode 日经贴,Cpp code -Linked List Cycle
- leetcode 日经贴,Cpp code -Linked List Cycle II
- leetcode 日经贴,Cpp code -Reverse Linked List
- leetcode 日经贴,Cpp code -Palindrome Linked List
- Leetcode 141. Linked List Cycle (Easy) (cpp)
- leetcode 日经贴,Cpp code -Flatten Binary Tree to Linked List
- leetcode 日经贴,Cpp code -Remove Linked List Elements
- leetcode 日经贴,Cpp code -Reverse Linked List II
- leetcode 日经贴,Cpp code -Delete Node in a Linked List
- Leetcode 142. Linked List Cycle II (Medium) (cpp)
- leetcode Linked List Cycle & Linked List Cycle ||
- 【LeetCode】Linked List Cycle
- Leetcode: Linked List Cycle
- Leetcode Linked List Cycle
- Leetcode: Linked List Cycle
- LeetCode:Linked List Cycle
- [LeetCode]Linked List Cycle
- LeetCode | Linked List Cycle
- Minimum Path Sum Total Accepted: 34975 Total Submissions: 109325
- Qt for Android - Internal Error: Could not find .pro file
- java中synchronized用法详解
- 求N(包含N)以内的质数 (python)
- Android中显示网页两种主要方式
- leetcode 日经贴,Cpp code -Linked List Cycle
- QT源码编译
- 全排列
- 全排列(含递归和非递归的解法)
- 【leetcode with java】4 Median of Two Sorted Arrays
- ZeroMemory、memset 和“={0}” 用于清零操作的区别 .
- WebView填坑——小功能篇
- 开源学习网站
- uva 1555(数学)