ByteDance interview question

Leet code easy and medium