Review Hashmap code problems

**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() |

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

See more blog_{posts}.