TikTok interview question

data structure design with O(1) complexity.