Path With Minimum Effort Leetcode Python