ByteDance interview question

To code a leetcode style question