Skip to content

Commit 7dcefd6

Browse files
committed
added task #1346 solution
1 parent 3a62a06 commit 7dcefd6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/task_1346/Solution.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package task_1346;
2+
3+
import java.util.HashSet;
4+
import java.util.Set;
5+
6+
public class Solution {
7+
public boolean checkIfExist(int[] arr) {
8+
Set<Integer> set = new HashSet<>();
9+
for (int i = 0; i < arr.length; i++) {
10+
if (set.contains(arr[i] * 2)) {
11+
return true;
12+
}
13+
if (arr[i] % 2 == 0 && set.contains(arr[i] / 2)) {
14+
return true;
15+
}
16+
set.add(arr[i]);
17+
}
18+
return false;
19+
}
20+
21+
}

0 commit comments

Comments
 (0)