---
# System prepended metadata

title: 0401. Binary Watch
tags: [Leetcode, Easy]

---

# 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;
    }
}
```