Skip to content

Commit 6679b94

Browse files
committed
Create: 0217-contains-duplicate.dart
1 parent d5d7762 commit 6679b94

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

dart/0217-contains-duplicate.dart

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Time Complexity: O(n)
2+
// Space Complexity: O(n)
3+
4+
class Solution {
5+
bool containsDuplicate(List<int> nums) {
6+
Set<int> hashSet = Set<int>();
7+
for (int n in nums) {
8+
if (hashSet.contains(n)) {
9+
return true;
10+
}
11+
hashSet.add(n);
12+
}
13+
return false;
14+
}
15+
}

0 commit comments

Comments
 (0)