Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- 컴퓨터과학
- 코드
- node.js
- computerscience
- 문자열처리
- node배포
- Simulated Annealing
- 알고리즘
- 파이썬
- AWS
- Hill Climbing
- CS
- Search Algorithm
- 컴퓨터공학
- 문자열
- Local Search
- typescript
- 철학
- lightsailor
- multer-s3
- 배포
Archives
- Today
- Total
지식의모듈화
[LeetCode][Javascript] LinkedList Problems 본문
141. Linked List Cycle
/**
* Definition for singly-linked list.
* function ListNode(val) {
* this.val = val;
* this.next = null;
* }
*/
/**
* @param {ListNode} head
* @return {boolean}
*/
var hasCycle = function(head) {
let fast= head;
let ans=false;
while(fast&&fast.next&&head){
head=head.next
fast=fast.next.next
if(head===fast) {
ans=true;
break;
}
}
return ans
};
'PS > LeetCode' 카테고리의 다른 글
[Leetcode][JavaScript] 55. Jump Game (0) | 2022.08.17 |
---|---|
[Leetcode][Javascript] 36. Valid Sudoku (0) | 2022.08.17 |
[LeetCode][JavaScript] DFS Problems (0) | 2022.08.04 |
[LeetCode][Javascript] Binary Search Tree Problems (0) | 2022.08.04 |
[CoderPad Interview] Problem 77 [Easy] (0) | 2022.08.04 |