Created
March 4, 2020 04:09
-
-
Save BharathKumarS/4d3b63c4dd4674290902d3efcbb3dbf2 to your computer and use it in GitHub Desktop.
LeetCode, Find the min time required to travel from start to end of the coordinates. Concept: list of list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Make use of the test cases, All test cases passed. Take a look at my git repo 'Py_Challenge_Accepted' | |
points = [[1,1],[3,4],[-1,0]] | |
#points = [[1,2],[2,2],[3,2],[0,-2],[4,3]] | |
#points = [[1,1],[3,4],[-1,0]] | |
#points = [[3,2],[-2,2]] | |
xDiff = yDiff = time = 0 | |
for i in range(len(points)-1): | |
xDiff = abs(points[i][0] - points[i+1][0]) | |
yDiff = abs(points[i][1] - points[i+1][1]) | |
time = time + max(xDiff, yDiff) | |
print(time) |
Author
BharathKumarS
commented
Mar 4, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment