
leetcode算法研究
倒四合天
我比较懒。。。比较懒。。。较懒。。。懒。。。
展开
-
leetcode884. 两句话中的不常见单词(java)
public String[] uncommonFromSentences(String A, String B) { Map<String, Integer> savemap = new HashMap<>(); List<String> list = new ArrayList<>(); saveS...原创 2018-08-22 15:07:41 · 522 阅读 · 0 评论 -
leetcode617. 合并二叉树
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */class Solution { pub...原创 2018-09-17 16:46:48 · 496 阅读 · 0 评论 -
leetcode709. 转换成小写字母
class Solution { public String toLowerCase(String str) { if (str.isEmpty()) { return null; } byte[] num = str.getBytes(); for (int i = 0; i < num.le...原创 2018-09-17 16:10:10 · 292 阅读 · 0 评论 -
leetcode461. 汉明距离
class Solution { public int hammingDistance(int x, int y) { int sum=x^y; int count; for(count=0;sum>0;count++){ sum&=sum-1; } return cou...原创 2018-09-17 14:44:17 · 170 阅读 · 0 评论 -
leetcode804. 唯一摩尔斯密码词(java)
public int uniqueMorseRepresentations(String[] words) { String[] numberstr = new String[]{".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", &原创 2018-08-21 15:57:55 · 590 阅读 · 0 评论 -
leetcode242. 有效的字母异位词(java)
public static boolean isAnagram(String s, String t) { if (s.equals(t)) { return true; } else if (null == s || null == t || s.length() != t.length() || s.length() <= 0) ...原创 2018-08-21 11:04:05 · 775 阅读 · 0 评论 -
leetcode1. 两数之和
public int[] twoSum(int[] nums, int target) { List<Integer> list = new ArrayList<>(); Boolean issum = checknum(nums, target, list, 0, false); if (issum) { ...原创 2018-08-23 15:23:42 · 211 阅读 · 0 评论 -
leetcode 125. 验证回文串(java版)
private static boolean isPalindrome(String s) { if(null==s||s.length()<2){//如果字符串的长度小于2,直接返回true return true; } int size=s.length()-1;//记载的总长度 char lef...原创 2018-08-20 16:54:50 · 799 阅读 · 0 评论 -
leetcode680. 验证回文字符串 Ⅱ(java)
public static boolean validPalindrome(String s) { if (s.length() <= 2) {//如果字符串长度小于等于2,直接返回true return true; } return checkResult(s, 0, s.length() - 1, 1);}private static...原创 2018-08-17 14:24:54 · 636 阅读 · 0 评论 -
leetcode771. 宝石与石头
public static int numJewelsInStones(String J, String S) { int result = 0; for (int i = 0; i < S.length(); i++) { for (int j = 0; j < J.length(); j++) { ...原创 2018-09-13 13:28:53 · 500 阅读 · 0 评论