Question d’entretien chez Baidu

Write codes for a question which is on leetcode.