File tree Expand file tree Collapse file tree 3 files changed +56
-0
lines changed
Div2_500_NumbersChallenge Expand file tree Collapse file tree 3 files changed +56
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments