Skip to content

Commit 2ae6175

Browse files
refactor 401
1 parent 9057442 commit 2ae6175

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
import 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
@@ -24,16 +24,18 @@
2424
*/
2525
public 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
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy