HashMap
文章平均质量分 77
Dylan_Java_NYC
练很重要,总结更重要,感谢CSDN给了我这么好的平台交流。
展开
-
LeetCode Substring with Concatenation of All Words
原题链接在这里: https://leetcode.com/problems/substring-with-concatenation-of-all-words/ 这道题思路与Longest Substring Without Repeating Characters 相似。 不同的是这道题需要先生成并维护一个字典,检查新词是否是字典里的词。同时维护一个窗口[start,end], 外层循环原创 2015-08-12 10:14:05 · 307 阅读 · 0 评论 -
LeetCode Minimum Window Substring
原题链接在这里: https://leetcode.com/problems/minimum-window-substring/ 又是一道双指针问题,与Longest Substring Without Repeating Characters, Substring with Concatenation of All Words相似。 维护一个字典和一个窗口,不同的地方是题目说contai原创 2015-08-13 04:51:50 · 327 阅读 · 0 评论 -
LeetCode Isomorphic Strings
原题链接在此:https://leetcode.com/problems/isomorphic-strings/ Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to原创 2015-07-23 04:41:14 · 422 阅读 · 0 评论 -
LeetCode Valid Anagram
原题链接在这里:https://leetcode.com/problems/valid-anagram/ 这道题可以用HashMap来解决,首先判断 s 和 t 长度是否相等,若不等返回 false。 若想等,对于s的每一个character存入hm,value是该character出现的次数。 然后遍历t的每一个character,从hm中相应减出去,若在减除过程中碰到hm中没有的char原创 2015-08-03 10:48:01 · 884 阅读 · 0 评论 -
LeetCode Fraction to Recurring Decimal
原题链接在这里:https://leetcode.com/problems/fraction-to-recurring-decimal/ 解这道题的思路就是观察remainder是否出现重复,若出现重复,就进入了infinite loop,需要加括号。 Note: 1. 注意检查corner case,若是 numerator 或 denominator 出现 0的时候,返回相应的值。原创 2015-08-04 04:51:00 · 255 阅读 · 0 评论