Skip to content

Commit 0d0395b

Browse files
committed
add time complexity
1 parent 0bd99fe commit 0d0395b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

linked-list-cycle/mmyeon.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ function hasCycle(head: ListNode | null): boolean {
4040
* - 사이클이 있으면 두 포인터가 결국 같은 노드를 가리키게 되므로 투 포인터 사용
4141
* - 사이클이 없는 경우를 위해서 tail노드의 null체크를 해야함
4242
*
43+
* 시간복잡도 : O(n)
44+
* - 순환 이전 노드의 개수 n만큼 순회하면서 순환 여부 확인
45+
*
4346
* 공간복잡도 : O(1)
4447
* - 추가 메모리없이 slow, fast 포인터만 사용하므로 O(1)
4548
*/

0 commit comments

Comments
 (0)