Skip to content

Commit a0f7fcd

Browse files
authored
Create Binary Watch.java
1 parent 515e7af commit a0f7fcd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Easy/Binary Watch.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public List<String> readBinaryWatch(int turnedOn) {
3+
return IntStream.range(0, 12)
4+
.boxed()
5+
.flatMap(
6+
h -> IntStream.range(0, 60)
7+
.boxed()
8+
.filter(s -> Integer.bitCount(h) + Integer.bitCount(s) == turnedOn)
9+
.map(m -> String.format("%d:%02d", h, m))
10+
)
11+
.collect(Collectors.toList());
12+
}
13+
}

0 commit comments

Comments
 (0)