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)