MCPcopy
hub / github.com/doocs/leetcode / readBinaryWatch

Method readBinaryWatch

solution/0400-0499/0401.Binary Watch/Solution.java:2–12  ·  view source on GitHub ↗
(int turnedOn)

Source from the content-addressed store, hash-verified

1class Solution {
2 public List<String> readBinaryWatch(int turnedOn) {
3 List<String> ans = new ArrayList<>();
4 for (int i = 0; i < 12; ++i) {
5 for (int j = 0; j < 60; ++j) {
6 if (Integer.bitCount(i) + Integer.bitCount(j) == turnedOn) {
7 ans.add(String.format("%d:%02d", i, j));
8 }
9 }
10 }
11 return ans;
12 }
13}

Callers

nothing calls this directly

Calls 2

formatMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected