hashtable
feeeeeeet
这个作者很懒,什么都没留下…
展开
-
Leetcode 3. Longest Substring Without Repeating Characters
public class Solution { public int lengthOfLongestSubstring(String s) { Map<Character,Integer> map =new HashMap<>(); int res =0,len=s.length(); for(int i=0,j=0;...原创 2018-11-11 06:08:22 · 77 阅读 · 0 评论 -
Leetcode 1. Two Sum
1.Two Sum@Leetcode 2 solutions-Brute Force & hash table Solution 1 Brute Force Loop through each element x find if there is another value that equals to target−x. class Solution { public int[]...原创 2018-11-09 23:31:13 · 97 阅读 · 0 评论 -
Leetcode 49. Group Anagrams
class Solution(object): def groupAnagrams(self, strs): """ :type strs: List[str] :rtype: List[List[str]] """ strings, res, ans = [], {}, [] for s in...原创 2018-12-05 23:38:09 · 57 阅读 · 0 评论 -
Leetcode 105 & 106. Construct Binary Tree from Preorder and Inorder & Inorder and Postorder
hash Use a dictionary to store the number in inorder and its index. Find position of the root in inorder in O(1). slow version # Definition for a binary tree node. # class TreeNode: # def __init__...原创 2019-01-18 05:36:16 · 106 阅读 · 0 评论