- 博客(5)
- 收藏
- 关注
转载 Java 位操作
转自:http://www.jianshu.com/p/b677858bc085 // 1. 获得int型最大值 System.out.println((1 << 31) - 1);// 2147483647, 由于优先级关系,括号不可省略 System.out.println(~(1 << 31));// 2147483647 // 2. 获得int型最小值 System.out.pri
2017-12-11 22:10:54 151
原创 leeetcode 400 Nth Digit
思路参考:https://discuss.leetcode.com/topic/59322/sharing-my-thinking-process 代码参考:https://discuss.leetcode.com/topic/59314/java-solution/14 Find the nth digit of the infinite integer sequence 1, 2,
2017-12-08 21:24:43 154
转载 Leetcode 255. Add Digits
最开始的思路: class Solution { public int addDigits(int num) { int tmp = num; while (tmp >= 10){ num = tmp; tmp = 0; while (num > 0){
2017-12-07 19:40:42 154
转载 leetcode 231. Power of Two & 326. Power of Three & 342. Power of Four
转载自 http://blog.csdn.net/hackbuteer1/article/details/6681157 将2的幂次方写成二进制形式后,很容易就会发现有一个特点:二进制中只有一个1,并且1后面跟了n个0; 因此问题可以转化为判断1后面是否跟了n个0就可以了。 如果将这个数减去1后会发现,仅有的那个1会变为0,而原来的那n个0会变为1;因此将原来的数与去减
2017-12-07 18:56:26 156
原创 leetcode 204 Count Primes
本题使用传统方法,时间复杂度过高,会超时。从discuss学习了两种新的方法。第一种方法: Sieve of Eratosthenes youtube视频讲解 class Solution { public int countPrimes(int n) { //Java对布尔数组初始化为false boolean[] nf = new bo
2017-12-06 21:05:13 140
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人