-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_401.java
25 lines (22 loc) · 799 Bytes
/
_401.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.fishercoder.solutions.firstthousand;
import java.util.ArrayList;
import java.util.List;
public class _401 {
public static class Solution1 {
public List<String> readBinaryWatch(int num) {
List<String> times = new ArrayList<>();
for (int h = 0; h < 12; h++) {
for (int m = 0; m < 60; m++) {
if (Integer.bitCount(h * 64 + m) == num) {
times.add(
String.format(
"%d:%02d",
h, m)); // %02 means to pad this two-digit decimal number on
// the left with zeroes
}
}
}
return times;
}
}
}