ByteDance interview question

Médium to easy leetcode problems.