File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change 44import java .util .List ;
55
66/**
7+ * 401. Binary Watch
8+ *
79 * 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.
1111
1212 For example, the above binary watch reads "3:25".
1313
2424 */
2525public class _401 {
2626
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+ }
3336 }
3437 }
38+ return times ;
3539 }
36- return times ;
3740 }
38-
3941}
You can’t perform that action at this time.
0 commit comments