Skip to content

Commit 6eddf6b

Browse files
committed
Add SRM 621.
1 parent e94efa8 commit 6eddf6b

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import java.util.*;
2+
public class MixingColors {
3+
4+
public int minColors(int[] colors) {
5+
Arrays.sort(colors);
6+
Set<Integer> set = new HashSet<Integer>();
7+
int n = colors.length;
8+
for(int i=0;i<n;i++){
9+
10+
}
11+
return 0;
12+
}
13+
14+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
public class TwoWaysSorting {
2+
3+
public String sortingMethod(String[] stringList) {
4+
boolean length = true, lexicographically = true;
5+
for (int i = 1; i < stringList.length; i++) {
6+
length = length
7+
&& (stringList[i - 1].length() < stringList[i].length());
8+
lexicographically = lexicographically
9+
&& (stringList[i - 1].compareTo(stringList[i]) < 0);
10+
}
11+
if (length && lexicographically)
12+
return "both";
13+
if (length)
14+
return "lengths";
15+
if (lexicographically)
16+
return "lexicographically";
17+
return "none";
18+
}
19+
20+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import java.util.*;
2+
3+
public class NumbersChallenge {
4+
5+
public int MinNumber(int[] S) {
6+
List<Integer> result = new ArrayList<Integer>();
7+
for (int i = 0; i < S.length; i++) {
8+
int n = result.size();
9+
for (int j = 0; j < n; j++) {
10+
result.add(result.get(j) + S[i]);
11+
}
12+
result.add(S[i]);
13+
}
14+
Set<Integer> set = new HashSet<Integer>();
15+
set.addAll(result);
16+
int i = 1;
17+
while (!set.add(i))
18+
i++;
19+
return i;
20+
}
21+
22+
}

0 commit comments

Comments
 (0)