首页 > 代码库 > binary-watch

binary-watch

https://leetcode.com/problems/binary-watch/// 参考 https://discuss.leetcode.com/topic/59374/simple-python-java// 非常棒的方法public class Solution {    public List<String> readBinaryWatch(int num) {        List<String> lt = new ArrayList<String>();        for (int m=0; m<12; m++) {            for (int n=0; n<60; n++) {                if (Integer.bitCount(m*64+n) == num) {                    lt.add(String.format("%d:%02d", m, n));                }            }        }        return lt;    }}

 

binary-watch