Python Problem Solving Leetcode Sql