Sollicitatievraag bij Tencent

SQL question and one basic algorithm that needs to be fully written in python.