John Deere interview question

leetcode question of python, sql.