ByteDance interview question

Data structure as well as algorithms