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.
2 parents 5e35fcb + 59119e5 commit 512e1f1Copy full SHA for 512e1f1
contains-duplicate/shinheekim.java
@@ -0,0 +1,15 @@
1
+import java.util.HashSet;
2
+import java.util.Set;
3
+
4
+class Solution {
5
+ public boolean containsDuplicate(int[] nums) {
6
+ Set<Integer> visited = new HashSet<>();
7
8
+ for (int n : nums){
9
+ if (!visited.add(n)){
10
+ return true;
11
+ }
12
13
+ return false; // 모든 값이 고유할 때
14
15
+}
two-sum/shinheekim.java
@@ -0,0 +1,16 @@
+ public int[] twoSum(int[] nums, int target) {
+ int[] result = new int[2];
+ for (int i = 0; i < nums.length; i++){
+ for (int j = i + 1; j < nums.length; j++){
+ if (nums[i] + nums[j] == target){
+ result[0] = i;
+ result[1] = j;
+ return result;
+ return null;
16
0 commit comments