ByteDance interview question

just coding. no questions for the first round