Domanda di colloquio di Baidu

Write codes for a question which is on leetcode.