摘要:
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 ... 阅读全文
摘要:
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(); ... 阅读全文
摘要:
https://leetcode.com/problems/arithmetic-slices/ public class Solution { public int numberOfArithmeticSlices(int[] A) { if (A.length < 3) { return 0; } int... 阅读全文
摘要:
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... 阅读全文
摘要:
https://leetcode.com/problems/battleships-in-a-board/ // 采用的是排除法,看船的最后一个节点 public class Solution { public int countBattleships(char[][] board) { int rows = board.length; int c... 阅读全文
摘要:
https://leetcode.com/problems/maximum-xor-of-two-numbers-in-an-array/ 利用了异或的”自反性“: a ^ b = c,而a ^ b ^ b = a, 则 c ^ b = a 其他运算定律有:交换律、结合律、分配律。 注意:计算使用的 阅读全文