上一页 1 2 3 4 5 6 7 ··· 33 下一页
摘要: class MaxQueue { Queue<Integer> queue; LinkedList<Integer> max; public MaxQueue() { queue = new LinkedList<>(); max = new LinkedList<>(); } public int 阅读全文
posted @ 2020-08-24 15:46 欣姐姐 阅读(91) 评论(0) 推荐(0) 编辑
摘要: public int maxProfit(int[] prices) { int n = prices.length; if(n == 0) return 0; int[] x = new int[n]; x[0] = prices[0]; int max = -1; for(int i = 1;i 阅读全文
posted @ 2020-08-24 15:02 欣姐姐 阅读(113) 评论(0) 推荐(0) 编辑
摘要: public int sumNums(int n) { boolean flag = n > 0 && (n+=sumNums(n-1))>0; return n; } public int sumNums(int n) { return IntStream.range(1,n+1).sum(); 阅读全文
posted @ 2020-08-24 10:09 欣姐姐 阅读(139) 评论(0) 推荐(0) 编辑
摘要: public boolean oneEditAway(String first, String second) { int m = first.length(); int n = second.length(); if(Math.abs(m-n)>1) return false; if(m == 0 阅读全文
posted @ 2020-08-22 14:27 欣姐姐 阅读(130) 评论(0) 推荐(0) 编辑
摘要: public boolean canPermutePalindrome(String s) { char[] c = s.toCharArray(); int n = c.length; Map<Character,Integer> map = new HashMap<>(); for (char 阅读全文
posted @ 2020-08-22 12:07 欣姐姐 阅读(176) 评论(0) 推荐(0) 编辑
摘要: public String replaceSpaces(String S, int length) { S = S.substring(0,length); char[] c = S.toCharArray(); StringBuilder sb = new StringBuilder(); for 阅读全文
posted @ 2020-08-22 11:48 欣姐姐 阅读(94) 评论(0) 推荐(0) 编辑
摘要: public boolean CheckPermutation(String s1, String s2) { char[] c1 = s1.toCharArray(); char[] c2 = s2.toCharArray(); int n = c1.length; if(n!=c2.length 阅读全文
posted @ 2020-08-22 11:26 欣姐姐 阅读(167) 评论(0) 推荐(0) 编辑
摘要: public boolean isUnique(String astr) { for(char x = 'a';x<='z';x++){ if(!(astr.indexOf(x)==astr.lastIndexOf(x))){ return false; } } return true; } 阅读全文
posted @ 2020-08-22 11:17 欣姐姐 阅读(121) 评论(0) 推荐(0) 编辑
摘要: public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) { if(root == null || root == p || root == q) return root; TreeNode left = 阅读全文
posted @ 2020-08-22 11:10 欣姐姐 阅读(82) 评论(0) 推荐(0) 编辑
摘要: public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) { if((root.val-p.val)*(root.val-q.val)<=0) return root; if(p.val<root.val& 阅读全文
posted @ 2020-08-22 10:05 欣姐姐 阅读(67) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 33 下一页