leetcode summary 10/15

692. Top K Frequent Words Python3 sorting using functools.total_ordering, implements eq and le 98. Validate Binary Search Tree 121. Best Time to Buy and Sell Stock get min price before current price 122. Best Time to Buy and Sell Stock II 123. Best Time to Buy and Sell Stock III 188. Best Time to Buy and Sell Stock IV 309. Best Time to Buy and Sell Stock with Cooldown

leetcode summary 10/14

76. Minimum Window Substring 242. Valid Anagram sort hashmap 139. Word Break memo s[i:] dp 49. Group Anagrams 387. First Unique Character in a String 283. Move Zeroes

System Design - TinyURL

Two methods Hash Function Pros: - use traditional hash function - randomly distributed - support url clean - hash functions cost time cons: - not short - collisions, start collisions from 2^(n/2). solution: url + timestamp Auto-increment index Base10, Base62 Pros: - simple, good with rdb - can be short - no conflicts cons: - not support url clean