leetCode 401. Binary Watch
来源:互联网 发布:手机荧屏软件 编辑:程序博客网 时间:2024/05/18 08:13
1.题目
原题链接
2.算法
我们用两个嵌套循环,外循环循环小时,内循环循环分
public class Solution { public List<String> readBinaryWatch(int num) { List<String> list = new ArrayList<String>(); if(num < 0) return list; for(int h=0; h<12; h++){ for(int m=0; m<60; m++){ if(Integer.bitCount(h) + Integer.bitCount(m) == num){ list.add(String.format("%d:%02d",h,m)); } } } return list; } }
0 0
- 【Leetcode】401. Binary Watch
- [LeetCode]401. Binary Watch
- LeetCode 401. Binary Watch
- [leetcode]401. Binary Watch
- Leetcode 401. Binary Watch
- LeetCode 401. Binary Watch
- LeetCode 401. Binary Watch
- LeetCode 401. Binary Watch
- leetcode 401. Binary Watch
- 【LeetCode】 401. Binary Watch
- [LeetCode]401. Binary Watch
- 401. [LeetCode]Binary Watch
- Leetcode 401. Binary Watch
- Leetcode: 401. Binary Watch
- LeetCode 401. Binary Watch
- 【Leetcode】401. Binary Watch
- Leetcode-401. Binary Watch
- leetCode 401. Binary Watch
- session与cookies的区别
- 谱聚类算法详解
- GDI+实现各种图像特效
- 吃货的终极梦想——嵌入式烤箱
- Spring4的IoC和DI的区别
- leetCode 401. Binary Watch
- NSURL 方法
- centos 7 安装pip
- javascript面向对象那点破事
- 完整的直播+点播全端解决方案
- 前端工具汇总
- 升级到struts-2.3.14.3之后涉及的改动以及ActionContextCleanUp,StrutsFilter详解
- 做一个IOS聊天APP如何实现发送/预览文件的功能
- struts2复合类型数据校验实例