Python solution not accepted due to TLE


#1

The solution is equivalent to the one described in the solution approach.