John Deere Interview Question

leetcode question of python, sql.