www

导航

上一页 1 2 3 4 5 6 7 ··· 9 下一页

2019年3月12日 #

滑动窗口-和为S的连续正数序列

摘要: package slidewindow;import java.util.ArrayList;import java.util.HashSet;import java.util.List;import java.util.Set;public class ContinuousSequence { p 阅读全文

posted @ 2019-03-12 18:59 www_practice 阅读(208) 评论(0) 推荐(0) 编辑

数组中的逆序对

摘要: public class Solution { public int InversePairs(int[] array) { if(array==null||array.length=start&&j>=mid+1){ if(array[i]>array[j]){ copy[index--]=array[i--]; ... 阅读全文

posted @ 2019-03-12 18:36 www_practice 阅读(151) 评论(0) 推荐(0) 编辑

数字在排序数组中出现的次数

摘要: public class Solution { public int GetNumberOfK(int[] array , int k) { if(array==null||array.length==0) return 0; int first=getFirstK(array,k); int lask=getLastK(array,k); i... 阅读全文

posted @ 2019-03-12 16:08 www_practice 阅读(129) 评论(0) 推荐(0) 编辑

2019年3月3日 #

单例模式(Java)

摘要: 注解:初试化静态的instance创建一次。如果我们在Singleton类里面写一个静态的方法不需要创建实例,它仍然会早早的创建一次实例。而降低内存的使用率。 缺点:没有lazy loading的效果,从而降低内存的使用率。 注解:定义一个私有的内部类,在第一次用这个嵌套类时,会创建一个实例。而类型 阅读全文

posted @ 2019-03-03 16:08 www_practice 阅读(112) 评论(0) 推荐(0) 编辑

2019年3月1日 #

最小的K个数

摘要: public class Solution { public ArrayList GetLeastNumbers_Solution(int [] input, int k) { ArrayList ret = new ArrayList(); if(k > input.length) return ret; PriorityQueue mi... 阅读全文

posted @ 2019-03-01 10:43 www_practice 阅读(136) 评论(0) 推荐(0) 编辑

数组中出现次数超过一半的数字

摘要: public int MoreThanHalfNum_Solution(int [] array) { if(array==null||array.length==0) return 0; int ret=array[0]; int times=1; for(int i=1; iarray.length/2) return ret; else return... 阅读全文

posted @ 2019-03-01 10:08 www_practice 阅读(142) 评论(0) 推荐(0) 编辑

字符串的排列

摘要: import java.util.*; public class Solution { public ArrayList Permutation(String str){ ArrayList ret = new ArrayList(); if(str!=null || str.length()>0){ helper(str.toCharArray(... 阅读全文

posted @ 2019-03-01 09:36 www_practice 阅读(125) 评论(0) 推荐(0) 编辑

2019年2月28日 #

二叉搜索树与双向链表

摘要: public class Solution { public TreeNode Convert(TreeNode pRootOfTree) { if(pRootOfTree == null) return null; if(pRootOfTree.left==null&&pRootOfTree.right==null) return pRootOfTree; ... 阅读全文

posted @ 2019-02-28 22:28 www_practice 阅读(92) 评论(0) 推荐(0) 编辑

二叉搜索树的后序遍历序列

摘要: public boolean VerifySquenceOfBST(int[] sequence) { if(sequence == null || sequence.length==0) return false; int start = 0, end = sequence.length-1; return helper(sequence, start, end); }... 阅读全文

posted @ 2019-02-28 19:35 www_practice 阅读(150) 评论(0) 推荐(0) 编辑

栈的压入、弹出序列

摘要: public boolean IsPopOrder(int [] pushA,int [] popA) { if(pushA == null || popA==null || pushA.length==0 || pushA.length!=popA.length) { return false; } Stack stack =... 阅读全文

posted @ 2019-02-28 18:57 www_practice 阅读(89) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 ··· 9 下一页