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 8901b1d commit 842f1fcCopy full SHA for 842f1fc
contains-duplicate/EcoFriendlyAppleSu.kt
@@ -0,0 +1,13 @@
1
+package leetcode_study
2
+
3
+/**
4
+ * Set 자료 구조로 변경 후 원소의 개수를 비교해 문제 해결
5
+ * 시간 복잡도 : O(n)
6
+ * -> 모든 Array의 원소를 순회해야함.
7
+ * 공간 복잡도 : O(n)
8
+ * -> IntArray의 요소 개수에 비례하여 추가적인 공간이 필요함.
9
+ */
10
+fun containsDuplicate(nums: IntArray): Boolean {
11
+ val changeSet = nums.toSet()
12
+ return changeSet.size != nums.size
13
+}
0 commit comments