# 0401. Binary Watch ###### tags: `Leetcode` `Easy` ## 注意 语法: ```Integer.bitCount()``` ```String.format()``` ## Code ```java= class Solution { public List<String> readBinaryWatch(int turnedOn) { List<String> ans = new ArrayList<>(); for(int i = 0;i < 12;i++){ for(int j = 0;j < 60;j++){ if(Integer.bitCount(i)+Integer.bitCount(j)==turnedOn){ ans.add(String.format("%d:%02d", i, j)); } } } return ans; } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up