Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2ae6175

Browse files
refactor 401
1 parent9057442 commit2ae6175

File tree

1 file changed

+13
-11
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+13
-11
lines changed

‎src/main/java/com/fishercoder/solutions/_401.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
importjava.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
@@ -24,16 +24,18 @@
2424
*/
2525
publicclass_401 {
2626

27-
publicList<String>readBinaryWatch(intnum) {
28-
List<String>times =newArrayList<>();
29-
for (inth =0;h <12;h++) {
30-
for (intm =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+
publicstaticclassSolution1 {
28+
publicList<String>readBinaryWatch(intnum) {
29+
List<String>times =newArrayList<>();
30+
for (inth =0;h <12;h++) {
31+
for (intm =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+
returntimes;
3539
}
36-
returntimes;
3740
}
38-
3941
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp