Design

Design TinyURL in LeetCode

Problem TinyUrl is a URL that a original URL is compressed. This problem is how should we design TinyURL services. https://leetcode.com/problems/design-tinyurl/#/solutionsDesign TinyURL - LeetCode How to code First, I prepare two HashMap t…

Implement function min which returns minimum element in stack

Problem How would you design a stack which, in addition to push and pop, also has a function min which return minimum element? Push, pop and min should all operate in O(1) time. How to Solve By keeping a minimum value at each state, we can…