摘要:
用sliding window的方法,之前还有个k不同元素好像也是类似的思路。有时间可以去复习下。 阅读全文
posted @ 2016-10-16 22:21
blcblc
阅读(965)
评论(0)
推荐(0)
摘要:
https://leetcode.com/problems/reconstruct-original-digits-from-english/ //https://discuss.leetcode.com/topic/63386/one-pass-o-n-java-solution-simple-and-clear public class Solution { // zero ... 阅读全文
posted @ 2016-10-16 20:56
blcblc
阅读(662)
评论(0)
推荐(0)
摘要:
https://leetcode.com/problems/third-maximum-number/ // 开始我以为相同的也占一位,比如5,3,3,2,得出3,但是答案是需要2 public class Solution { public int thirdMax(int[] nums) { List lst = new ArrayList(); ... 阅读全文
posted @ 2016-10-16 20:11
blcblc
阅读(398)
评论(0)
推荐(0)
摘要:
我自己做出来的,分了几种情况来考虑。(再后面有加了注释的版本) 以下是加了注释的版本: 准备发表在Discuss版: https://discuss.leetcode.com/category/549/strong-password-checker 阅读全文
posted @ 2016-10-16 15:41
blcblc
阅读(1191)
评论(0)
推荐(0)
摘要:
https://leetcode.com/problems/arithmetic-slices/ public class Solution { public int numberOfArithmeticSlices(int[] A) { if (A.length < 3) { return 0; } int... 阅读全文
posted @ 2016-10-16 14:52
blcblc
阅读(246)
评论(0)
推荐(0)
摘要:
https://leetcode.com/problems/fizz-buzz/ public class Solution { public List fizzBuzz(int n) { List lst= new ArrayList(); for (int i=1; i<=n; i++) { if (i % 15 == 0... 阅读全文
posted @ 2016-10-16 14:21
blcblc
阅读(290)
评论(0)
推荐(0)
摘要:
https://leetcode.com/problems/battleships-in-a-board/ // 采用的是排除法,看船的最后一个节点 public class Solution { public int countBattleships(char[][] board) { int rows = board.length; int c... 阅读全文
posted @ 2016-10-16 14:15
blcblc
阅读(275)
评论(0)
推荐(0)
摘要:
https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/ 利用了异或的”自反性“: a ^ b = c,而a ^ b ^ b = a, 则 c ^ b = a 其他运算定律有:交换律、结合律、分配律。 注意:计算使用的 阅读全文
posted @ 2016-10-16 12:23
blcblc
阅读(2706)
评论(2)
推荐(0)
摘要:
开始实验这个,是因为Redis实战.pdf上面有例子。 上面用的是 org.jredis包,可是发现这个包不在maven的公共仓库里。需要先下载然后放在本地,导入maven依赖。详见: http://blog.csdn.net/zhu_tianwei/article/details/44900955 阅读全文
posted @ 2016-10-16 09:27
blcblc
阅读(6976)
评论(0)
推荐(1)
摘要:
Java String格式话参数整理如下: C++ String格式化参数整理如下: PHP String格式化参数整理如下: Python String格式化参数整理如下: Javascript String格式化参数整理如下: 原生语言,没有 Node中有sprintf包,见 https://n 阅读全文
posted @ 2016-10-16 08:17
blcblc
阅读(843)
评论(0)
推荐(0)