HashMap
qq_38959715
这个作者很懒,什么都没留下…
展开
-
Java/389. Find the Difference 找不同
题目 代码部分一(14ms 36.69%)class Solution { public char findTheDifference(String s, String t) { char res = ' '; Map<Character, Integer> mapS = new HashMap<Characte...转载 2018-09-25 10:50:20 · 997 阅读 · 0 评论 -
Java/706. Design HashMap 设计哈希映射
题目 代码部分一(138ms 79.22%)class MyHashMap { private final int BLOCK = 1000005; int[] nums; boolean[] map; /** Initialize your data structure here. */ public MyHas...转载 2018-10-12 22:51:52 · 1234 阅读 · 0 评论 -
Java/447. Number of Boomerangs 回旋镖的数量
题目 代码部分(148ms 89.76%)class Solution { public int numberOfBoomerangs(int[][] points) { int result = 0; int dis = 0; int freq = 0; int tempRes = 0; ...转载 2018-10-12 23:10:23 · 906 阅读 · 0 评论 -
Java/242. Valid Anagram 有效的字母异位词
题目 代码部分一(6ms 71.86%)class Solution { public boolean isAnagram(String s, String t) { int n1 = s.length(); int n2 = t.length(); if(n1 != n2)return false; ...转载 2018-09-29 10:01:41 · 653 阅读 · 0 评论 -
Java/205. Isomorphic String 同构字符串
题目 代码部分一(5ms,96.64%)class Solution { public boolean isIsomorphic(String s, String t) { int[] map1 = new int[1000]; int[] map2 = new int[1000]; int...转载 2018-09-29 10:08:31 · 610 阅读 · 0 评论 -
Java/217. Contains Duplicate 存在重复数字
题目 代码部分一(27ms 30.81%)class Solution { public boolean containsDuplicate(int[] nums) { if(nums == null || nums.length == 0) return false; Map<Integer, In...转载 2018-09-29 10:12:25 · 673 阅读 · 0 评论 -
Java/599. Minimum Index Sum of Two Lists 两个列表的最小索引总和
题目 代码部分一(26ms 55.61%)class Solution { public String[] findRestaurant(String[] list1, String[] list2) { int len1 = list1.length; int len2 = list2.length; if...转载 2018-10-08 21:21:57 · 738 阅读 · 0 评论 -
Java/290. Word Pattern 单词模式
题目 代码部分一(1ms 89.86%)class Solution { public boolean wordPattern(String pattern, String str) { char[] ch = pattern.toCharArray(); if(ch.length == 0 || str.length() == ...转载 2018-10-08 23:40:16 · 647 阅读 · 0 评论 -
Java/594. Longest Harmonious Subsequence 最长和谐子序列
题目代码部分一(73ms 34.54%)class Solution { public int findLHS(int[] nums) { if(nums == null || nums.length == 0) return 0; int res = 0; int cur = 0, ne...转载 2018-10-09 21:13:33 · 629 阅读 · 0 评论 -
Java/705. Design HashSet 设计哈希集合
题目 代码部分一(150ms 48.40%)class MyHashSet { /** Initialize your data structure here. */ int[] map = new int[1000005]; public MyHashSet() { } public void...转载 2018-10-12 22:39:43 · 962 阅读 · 0 评论 -
Java/811. Subdomain Vist Count 子域名访问计数
题目 代码部分一(23ms 89.75%)class Solution { public List<String> subdomainVisits(String[] cpdomains) { List<String> res = new ArrayList<>(); Map<...转载 2018-10-12 22:31:21 · 634 阅读 · 0 评论 -
Java/202. Happy Number 快乐数
题目 代码部分一(3ms 92.36%)class Solution { public boolean isHappy(int n) { Set<Integer> set = new HashSet<>(); while(n != 1 && !set.contains(n)){ ...转载 2018-09-25 22:22:01 · 949 阅读 · 0 评论 -
Java/387. First Unique Character in a String 字符串中第一个唯一字符
题目代码部分一(10ms 95.56%)class Solution { public int firstUniqChar(String s) { char[] ch = s.toCharArray(); int[] map = new int[256]; int res = -1; ...转载 2018-10-01 23:16:26 · 784 阅读 · 0 评论 -
Java/350. Intersection of Two Arrays II 两个数组的交集 II
题目 代码部分一(4ms 85.80%)class Solution { public int[] intersect(int[] nums1, int[] nums2) { List<Integer> list = new ArrayList<>(); Map<Integer, Integer...转载 2018-10-01 23:17:48 · 754 阅读 · 0 评论 -
Java/645. Set Mismatch 错误的集合
题目 代码部分一(6ms 100%)class Solution { public int[] findErrorNums(int[] nums) { int[] res = new int[2]; int[] index = new int[nums.length + 1]; for(int i = 0; ...转载 2018-10-01 23:33:57 · 615 阅读 · 0 评论 -
Java/204. Count Primes 计数质数
题目 代码部分一(246ms, 15.70%)class Solution { public int countPrimes(int n) { if(n < 2) return 0; int res = 0; for(int i = 2; i < n; i++){ res ...转载 2018-10-02 23:25:04 · 647 阅读 · 0 评论 -
Java/409. Longest Palindrome 最长回文串
题目 代码部分一(14ms 63.68%)class Solution { public int longestPalindrome(String s) { int len = s.length(); Map<Character, Integer> map = new HashMap<&g...转载 2018-09-27 08:54:16 · 678 阅读 · 0 评论 -
Java/575. Distribute Candies 分糖果
题目 代码部分一(73ms,82.46%)class Solution { public int distributeCandies(int[] candies) { Map<Integer, Integer> sister = new HashMap<Integer, Integer>(); int...转载 2018-09-22 18:11:19 · 648 阅读 · 0 评论 -
Java/136. Single Number 只出现一次的数字
题目 代码部分一(17ms 26.66%)class Solution { public int singleNumber(int[] nums) { Map<Integer, Integer> map = new HashMap<Integer, Integer>(); for(int i = 0;...转载 2018-09-22 18:55:51 · 711 阅读 · 0 评论 -
Java/219. Contains Diplicate II 存在重复元素 II
题目 代码部分一(1113ms 2.25%)class Solution { public boolean containsNearbyDuplicate(int[] nums, int k) { if(k < 0) return false; for(int i = 0; i < nums.l...转载 2018-10-09 21:23:11 · 664 阅读 · 0 评论