5 lines Java


  • 0
    W
    private static final Map<Integer, List<String>> RES = new HashMap<>();
    static {
      for (int i = 0; i < 12; i++)
        for (int j = 0; j < 60; j++)
          RES.computeIfAbsent(Integer.bitCount(j | i << 6), k -> new ArrayList<>()).add(String.format("%d:%02d", i, j));
    }
    public List<String> readBinaryWatch(int num) {
      return num > 8 ? new ArrayList<>() : RES.get(num);
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.