Amazon interview question

SQL and python leetcode hard qns