File tree 1 file changed +13
-11
lines changed
src/main/java/com/fishercoder/solutions 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change 4
4
import java .util .List ;
5
5
6
6
/**
7
+ * 401. Binary Watch
8
+ *
7
9
* A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59).
8
-
9
- Each LED represents a zero or one, with the least significant bit on the right.
10
-
10
+ * Each LED represents a zero or one, with the least significant bit on the right.
11
11
12
12
For example, the above binary watch reads "3:25".
13
13
24
24
*/
25
25
public class _401 {
26
26
27
- public List <String > readBinaryWatch (int num ) {
28
- List <String > times = new ArrayList <>();
29
- for (int h = 0 ; h < 12 ; h ++) {
30
- for (int m = 0 ; m < 60 ; m ++) {
31
- if (Integer .bitCount (h * 60 + m ) == num ) {
32
- times .add (String .format ("%d:%02d" , h , m ));//%02 means to pad this two-digit decimal number on the left with zeroes
27
+ public static class Solution1 {
28
+ public List <String > readBinaryWatch (int num ) {
29
+ List <String > times = new ArrayList <>();
30
+ for (int h = 0 ; h < 12 ; h ++) {
31
+ for (int m = 0 ; m < 60 ; m ++) {
32
+ if (Integer .bitCount (h * 60 + m ) == num ) {
33
+ times .add (String .format ("%d:%02d" , h ,
34
+ m ));//%02 means to pad this two-digit decimal number on the left with zeroes
35
+ }
33
36
}
34
37
}
38
+ return times ;
35
39
}
36
- return times ;
37
40
}
38
-
39
41
}
You can’t perform that action at this time.
0 commit comments