We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f2b9477 commit aa93499Copy full SHA for aa93499
โlinked-list-cycle/gmlwls96.ktโ
@@ -0,0 +1,16 @@
1
+class Solution {
2
+ // ์๊ฐ : O(n)
3
+ // ์ธํธ์ head.val ๊ฐ์ ์ถ๊ฐํ๋ฉด์ ๋์ผํ ๊ฐ์ด ์๋์ง ์ฒดํฌ. ๋์ผํ ๊ฐ์ด ์กด์ฌํ๋ฉด ์ํํ๋ค๊ณ ํ๋จ.
4
+ fun hasCycle(head: ListNode?): Boolean {
5
+ val set = mutableSetOf<Int>()
6
+ var next = head
7
+ while (next != null) {
8
+ if (set.contains(next.`val`)) {
9
+ return true
10
+ }
11
+ set.add(next.`val`)
12
+ next = next.next
13
14
+ return false
15
16
+}
โlongest-substring-without-repeating-characters/gmlwls96.ktโ
0 commit comments