摘要:
代码:public class Solution { public void moveZeroes(int[] nums) { int i = 0, j = 0; while(ji) nums[i] = nums[j]; i++; ... 阅读全文
摘要:
注意整型数溢出的情况 用recursion做:代码:/* The isBadVersion API is defined in the parent class VersionControl. boolean isBadVersion(int version); */public clas... 阅读全文
摘要:
代码:public class Solution { public boolean isUgly(int num) { if(num == 0) return false; //if(num == 1 || num == 2 || num == 3 || num =... 阅读全文
摘要:
数学规律:https://en.wikipedia.org/wiki/Digital_root代码:public class Solution { public int addDigits(int num) { return 1+(num-1)%9; }} 阅读全文
摘要:
代码:/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) ... 阅读全文
摘要:
创建两个数组存储字母的个数,再对比两个数组是否相同代码:public class Solution { public boolean isAnagram(String s, String t) { int[] alphabets1 = new int[26]; in... 阅读全文
摘要:
代码:/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */pub... 阅读全文
摘要:
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { v... 阅读全文
摘要:
代码:class MyQueue { // Push element x to the back of queue. Stack stack = new Stack(); Stack aux = new Stack(); public void push(int x) { ... 阅读全文
摘要:
Two's complement of integer:https://zh.wikipedia.org/wiki/%E4%BA%8C%E8%A3%9C%E6%95%B8Bit Manipulation:https://docs.oracle.com/javase/tutorial/java/nut... 阅读全文
摘要:
Functions of StringBuilder:代码:public class Solution { public List summaryRanges(int[] nums) { List list = new ArrayList(); if(nums.le... 阅读全文