Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Solution {
- public List<String> readBinaryWatch(int num) {
- List<String> times = new ArrayList<String>();
- for(int h=0; h<12; h++) {
- for(int m=0; m<60; m++) {
- if(Integer.bitCount(h) + Integer.bitCount(m) == num) {
- times.add(String.format("%d:%02d", h, m));
- }
- }
- }
- return times;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement