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