Review Hashmap code problems

**Top Questions**

Name | Example |
---|---|

Use a local hashmap, instead of a global one | LeetCode: Increasing Subsequences |

One hashmap vs two hashmap | LeetCode: Before and After Puzzle |

Hashmap may make code more complicated | LeetCode: Find K-th Smallest Pair Distance |

Mapping data range of getRand algorithm | LeetCode: Implement Rand10() Using Rand7() |

Contains Duplicate II | Leetcode: Contains Duplicate II |

Rolling hash |

- Use a tuple as key

## Blog link: https://code.dennyzhang.com/group-shifted-strings class Solution: def groupStrings(self, strings): """ :type strings: List[str] :rtype: List[List[str]] """ import collections m = collections.defaultdict(list) for s in strings: # ba -> (0, 25) # az -> (0, 25) tup = tuple([(ord(ch)-ord(s[0]))%26 for ch in s]) m[tup].append(s) return [m[key] for key in m]

See all hashmap problems: #hashmap

- Review: Hashmap Problems
- LintCode: Word Frequency Count
- LintCode: Valid Array
- LintCode: Same Number
- LintCode: Longest AB Substring
- LintCode: Function Runtime
- LintCode: Fermat Point Of Graphs
- LeetCode: X of a Kind in a Deck of Cards
- LeetCode: Vowel Spellchecker
- LeetCode: Verifying an Alien Dictionary
- LeetCode: Unique Word Abbreviation
- LeetCode: Unique Number of Occurrences
- LeetCode: Unique Morse Code Words
- LeetCode: Unique Email Addresses
- LeetCode: Uncommon Words from Two Sentences
- LeetCode: Two Sum IV – Input is a BST
- LeetCode: Triples with Bitwise AND Equal To Zero
- LeetCode: Sum of Distances in Tree
- LeetCode: Subdomain Visit Count
- LeetCode: Subarray Sum Equals K
- LeetCode: Split Array with Equal Sum
- LeetCode: Smallest Integer Divisible by K
- LeetCode: Simplified Fractions
- LeetCode: Shortest Word Distance II
- LeetCode: Shortest Completing Word
- LeetCode: Sentence Similarity
- LeetCode: Reduce Array Size to The Half
- LeetCode: People Whose List of Favorite Companies Is Not a Subset of Another List
- LeetCode: Pairs of Songs With Total Durations Divisible by 60
- LeetCode: Number of Distinct Islands
- LeetCode: Number of Boomerangs
- LeetCode: Number of Atoms
- LeetCode: Minimum Number of Frogs Croaking
- LeetCode: Minimum Area Rectangle II
- LeetCode: Maximum Number of Balloons
- LeetCode: Make Two Arrays Equal by Reversing Sub-arrays
- LeetCode: Longest String Chain
- LeetCode: Longest Repeating Substring
- LeetCode: Longest Harmonious Subsequence
- LeetCode: Longest Duplicate Substring
- LeetCode: Line Reflection
- LeetCode: Largest Component Size by Common Factor
- LeetCode: Kill Process
- LeetCode: K-diff Pairs in an Array
- LeetCode: Jump Game IV
- LeetCode: Jewels and Stones
- LeetCode: Intersection of Two Arrays
- LeetCode: Increasing Subsequences
- LeetCode: H-Index
- LeetCode: Group Shifted Strings
- LeetCode: Group Anagrams
- LeetCode: Graph Valid Tree
- LeetCode: Friends Of Appropriate Ages
- LeetCode: Fraction to Recurring Decimal
- LeetCode: First Unique Number
- LeetCode: Find Words That Can Be Formed by Characters
- LeetCode: Find Smallest Common Element in All Rows
- LeetCode: Find Duplicate Subtrees
- LeetCode: Find Duplicate File in System
- LeetCode: Find and Replace Pattern
- LeetCode: Fair Candy Swap
- LeetCode: Distinct Echo Substrings
- LeetCode: Diagonal Traverse II
- LeetCode: Destination City
- LeetCode: Design Underground System
- LeetCode: Design Excel Sum Formula
- LeetCode: Counting Elements
- LeetCode: Count Vowels Permutation
- LeetCode: Count Number of Nice Subarrays
- LeetCode: Contains Duplicate II
- LeetCode: Contains Duplicate
- LeetCode: Confusing Number
- LeetCode: Check If N and Its Double Exist
- LeetCode: Check If a String Contains All Binary Codes of Size K
- LeetCode: Brick Wall
- LeetCode: Array of Doubled Pairs
- LeetCode: 4Sum II

See more blog posts.