摘要:
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
欣姐姐
阅读(142)
评论(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
欣姐姐
阅读(180)
评论(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
欣姐姐
阅读(97)
评论(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
欣姐姐
阅读(177)
评论(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
欣姐姐
阅读(127)
评论(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
欣姐姐
阅读(92)
评论(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
欣姐姐
阅读(74)
评论(0)
推荐(0)
摘要:
public int[] constructArr(int[] a) { int len = a.length; if(len == 0) return new int[0]; int[] b = new int[len]; return multiply(a,b,len); } private i 阅读全文
posted @ 2020-08-22 09:59
欣姐姐
阅读(93)
评论(0)
推荐(0)
摘要:
public int add(int a, int b) { int sum ,carry; do{ sum = a^b; carry = (a&b)<<1; a = sum; b = carry; }while(carry!=0); return a; } 阅读全文
posted @ 2020-08-22 09:40
欣姐姐
阅读(70)
评论(0)
推荐(0)
摘要:
public int lastRemaining(int n, int m) { ArrayList<Integer> list = new ArrayList<>(n); for (int i = 0; i < n; i++) { list.add(i); } int idx = 0; while 阅读全文
posted @ 2020-08-22 09:29
欣姐姐
阅读(114)
评论(0)
推荐(0)

浙公网安备 33010602011771号