摘要: import java.util.LinkedList; import java.util.Queue; class MyStack { Queue q1=new LinkedList(); Queue q2=new LinkedList(); // Push element x onto stack. public void push(in... 阅读全文
posted @ 2016-07-12 21:32 阿怪123 阅读(106) 评论(0) 推荐(0) 编辑
摘要: import java.util.ArrayList; import java.util.List; /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(i... 阅读全文
posted @ 2016-07-12 20:50 阿怪123 阅读(163) 评论(0) 推荐(0) 编辑
摘要: java当中的基本数据类型在函数中传递是值传递。 而对象的传递方式是引用,所以这里可以把boolean包裹在一个对象当中,来作为一个全局的引用使用 阅读全文
posted @ 2016-07-12 19:02 阿怪123 阅读(145) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int[] plusOne(int[] digits) { int size=digits.length; int isOverload=0; for(int i=size-1;i>=0;i--) { if(digits[i]==9) ... 阅读全文
posted @ 2016-07-12 17:41 阿怪123 阅读(147) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int addDigits(int num) { int temp=num; while(temp/10!=0) { int res=temp%10; while(temp/10!=0) { ... 阅读全文
posted @ 2016-07-12 17:33 阿怪123 阅读(104) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int missingNumber(int[] nums) { int size=nums.length; int res[]=new int[size+1]; for(int i=0;i<=size;i++) { ... 阅读全文
posted @ 2016-07-12 17:25 阿怪123 阅读(97) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int hIndex(int[] citations) { int answer=0; int size=citations.length; for(int i=0;itemp?answer:temp; } return answer; ... 阅读全文
posted @ 2016-07-12 17:21 阿怪123 阅读(139) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int hIndex(int[] citations) { int size=citations.length; int answer=0; int[] res=new int[size+1]; //对于res数组进行初始化 f... 阅读全文
posted @ 2016-07-12 17:08 阿怪123 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 注意大数溢出的问题 阅读全文
posted @ 2016-07-12 16:46 阿怪123 阅读(149) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public boolean isUgly(int num) { if(num==0) return false; if(num==1) return true; else { int t... 阅读全文
posted @ 2016-07-12 11:43 阿怪123 阅读(170) 评论(0) 推荐(0) 编辑