mirror of
https://github.com/chefyuan/algorithm-base.git
synced 2025-08-04 15:01:35 +00:00
代码重构 【Github Actions】
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
> 如果阅读时,发现错误,或者动画不可以显示的问题可以添加我微信好友 **[tan45du_one](https://raw.githubusercontent.com/tan45du/tan45du.github.io/master/个人微信.15egrcgqd94w.jpg)** ,备注 github + 题目 + 问题 向我反馈
|
||||
> 如果阅读时,发现错误,或者动画不可以显示的问题可以添加我微信好友 **[tan45du_one](https://raw.githubusercontent.com/tan45du/tan45du.github.io/master/个人微信.15egrcgqd94w.jpg)** ,备注 github + 题目 + 问题 向我反馈
|
||||
>
|
||||
> 感谢支持,该仓库会一直维护,希望对各位有一丢丢帮助。
|
||||
>
|
||||
> 另外希望手机阅读的同学可以来我的 <u>[**公众号:袁厨的算法小屋**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u> 两个平台同步,想要和题友一起刷题,互相监督的同学,可以在我的小屋点击<u>[**刷题小队**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u>进入。
|
||||
> 另外希望手机阅读的同学可以来我的 <u>[**公众号:袁厨的算法小屋**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u> 两个平台同步,想要和题友一起刷题,互相监督的同学,可以在我的小屋点击<u>[**刷题小队**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u>进入。
|
||||
|
||||
### [141. 环形链表](https://leetcode-cn.com/problems/linked-list-cycle/)
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
|
||||
#### 题目描述
|
||||
|
||||
> 给定一个链表,判断链表中是否有环。pos代表环的入口,若为-1,则代表无环。
|
||||
> 给定一个链表,判断链表中是否有环。pos 代表环的入口,若为-1,则代表无环。
|
||||
>
|
||||
> 如果链表中存在环,则返回 true 。否则,返回 false 。
|
||||
|
||||
示例1:
|
||||
示例 1:
|
||||
|
||||

|
||||
|
||||
@@ -34,11 +34,10 @@
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
**题目代码**
|
||||
|
||||
Java Code:
|
||||
|
||||
```java
|
||||
public class Solution {
|
||||
public boolean hasCycle(ListNode head) {
|
||||
@@ -79,17 +78,17 @@ public:
|
||||
JS Code:
|
||||
|
||||
```javascript
|
||||
var hasCycle = function(head) {
|
||||
let fast = head;
|
||||
let slow = head;
|
||||
while (fast && fast.next) {
|
||||
fast = fast.next.next;
|
||||
slow = slow.next;
|
||||
if (fast === slow) {
|
||||
return true;
|
||||
}
|
||||
var hasCycle = function (head) {
|
||||
let fast = head;
|
||||
let slow = head;
|
||||
while (fast && fast.next) {
|
||||
fast = fast.next.next;
|
||||
slow = slow.next;
|
||||
if (fast === slow) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user