Tag: data structure
A stack is a first-in-last-out (FILO) data structure. We all know that the list/array in Python is very powerful, that it can be used as a stack itself. For …
Design and implement a TwoSum class. It should support the following operations: add and find. add – Add the number to an internal data structure. find – Find if …
The Trie is common used data structure to speed up the word searching. The Trie is a structure to index the words character by character. Trie Definition in C++ …
Design a hit counter which counts the number of hits received in the past 5 minutes. Each function accepts a timestamp parameter (in seconds granularity) and you may assume …
Task: Design a Data Structure (Container) that supports O(1) constant time in Adding, Removing and Getting a Random Element with Equal Probability. For example: // RandomDS.add(3) // RandomDS.add(4) // …