일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 쓰릴오브파이트
- 미드시청
- 링피트
- 리얼 클래스
- 영어원서읽기
- 괜찮음
- 읽기
- 화상영어
- 30분
- English
- realclass
- 잡생각
- 매일
- 3줄정리
- FIT XR
- 만화도
- 파비최
- 뭐든
- 프로젝트
- leetcode
- Problem Solving
- Writing
- 개발자
- 영어공부
- 10분
- Daily Challenge
- 스탭퍼
- 월간
- 사이드
- 운동
Archives
- Today
- Total
파비의 매일매일 공부기록
2023.09.03 Today's Challenge 본문
https://leetcode.com/problems/linked-list-cycle/
Linked List Cycle - LeetCode
Can you solve this real interview question? Linked List Cycle - Given head, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by continuo
leetcode.com
투 포인터나 해쉬 테이블로 푸는 문제.
class Solution:
def hasCycle(self, head: Optional[ListNode]) -> bool:
visited_nodes = set()
current_node = head
while current_node:
if current_node in visited_nodes:
return True
visited_nodes.add(current_node)
current_node = current_node.next
return False
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
2023.09.05 Today's Challenge (0) | 2023.09.05 |
---|---|
2023.09.04 Today's Challenge (0) | 2023.09.04 |
2023.09.02 Today's Challenge (0) | 2023.09.02 |
2023.09.01 Today's Challenge (0) | 2023.09.01 |
2023.08.31 Today's Challenge (0) | 2023.08.31 |
Comments