HashMap
文章平均质量分 60
WayneShan
这个作者很懒,什么都没留下…
展开
-
【LeetCode】【JAVA】【057】Longest Consecutive Sequence
题目: Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, Given [100, 4, 200, 1, 3, 2], The longest consecutive elements sequence is [原创 2015-02-26 01:50:06 · 146 阅读 · 0 评论 -
【LeetCode】【JAVA】【080】Two Sum
题目: Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target,原创 2015-04-03 11:37:35 · 138 阅读 · 0 评论 -
【LeetCode】【JAVA】【085】Word Break II
题目:https://leetcode.com/problems/word-break-ii/ 思路: 直接用 Recursion超时。取 Word Break 的思路,先 DP 获得 jth 位置可达到的 index,再通过 Recursion 获得所有结果。 Code: public class Solution { ArrayList resAL;原创 2015-04-29 23:29:34 · 163 阅读 · 0 评论 -
【LeetCode】【JAVA】【085】Isomorphic Strings
题目:https://leetcode.com/problems/isomorphic-strings/ 思路: 题目要求 s 到 t 不能同时 map 两个,t 到 s 也不可以。但两个映射是独立的。 第一次用两个HashMap做,第二次用一个HashMap 一个 HashSet ,HashSet 用来检测重复。两种方法耗时一样。 Code: public原创 2015-04-30 08:58:29 · 180 阅读 · 0 评论