Sollicitatievraag bij Huawei Technologies

please write a algorithm question, this question is mainly leetcode medium level.