Skip to content

Commit 08d7f5d

Browse files
committed
Add solutions for problems 1684, 2413, 3280, and 3289
1 parent b8d95ef commit 08d7f5d

File tree

4 files changed

+96
-0
lines changed

4 files changed

+96
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package me.darksnakex.problems;
2+
3+
public class p1684 {
4+
5+
public int countConsistentStrings(String allowed, String[] words) {
6+
7+
int res = 0;
8+
9+
for (String word : words) {
10+
String pal = word;
11+
for (int j = 0; j < allowed.length(); j++) {
12+
pal = pal.replaceAll(String.valueOf(allowed.charAt(j)), "");
13+
}
14+
if (pal.isEmpty()) {
15+
res++;
16+
}
17+
}
18+
19+
return res;
20+
21+
22+
}
23+
24+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package me.darksnakex.problems;
2+
3+
public class p2413 {
4+
5+
public int smallestEvenMultiple(int n) {
6+
7+
for(double i = 2; i<n*10; i++){
8+
if(i % 2 == 0 && (i/n)%1 == 0){
9+
return (int)i;
10+
}
11+
}
12+
return n;
13+
14+
}
15+
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package me.darksnakex.problems;
2+
3+
public class p3280 {
4+
5+
public String convertDateToBinary(String date) {
6+
7+
int anio = Integer.parseInt(date.substring(0,4));
8+
int mes = Integer.parseInt(date.substring(5,7));
9+
int dia = Integer.parseInt(date.substring(8,10));
10+
11+
12+
return Integer.toBinaryString(anio)+"-"+Integer.toBinaryString(mes)+"-"+Integer.toBinaryString(dia);
13+
14+
}
15+
16+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package me.darksnakex.problems;
2+
3+
import java.util.HashMap;
4+
import java.util.Map;
5+
6+
public class p3289 {
7+
8+
public int[] getSneakyNumbers(int[] nums) {
9+
10+
Map<Integer,Integer> map = new HashMap<>();
11+
12+
int val1=-1;
13+
int val2=-1;
14+
for (int num : nums) {
15+
if (!map.containsKey(num)) {
16+
map.put(num, 1);
17+
} else {
18+
map.put(num, map.get(num) + 1);
19+
}
20+
21+
}
22+
for (int valor : map.keySet()) {
23+
if((map.get(valor))== 2){
24+
if(val1 == -1){
25+
val1 = valor;
26+
} else if (val2 == -1) {
27+
val2 = valor;
28+
}
29+
else{
30+
break;
31+
}
32+
}
33+
34+
}
35+
36+
return new int[]{val1,val2};
37+
38+
}
39+
40+
}

0 commit comments

Comments
 (0)