I need to store a set of n numbers from 1 to 10^9, such that
- Initialization takes O(n) time - it is mathematical expectation
- Search takes O(1) time - it is the worst case
- Structure takes O(n) memory
Could you help me to understand whether it is possible to implement it and how?
I think one can use hash functions or search trees for it.