Skip to content

Instantly share code, notes, and snippets.

@BharathKumarS
Created March 4, 2020 04:09
Show Gist options
  • Save BharathKumarS/4d3b63c4dd4674290902d3efcbb3dbf2 to your computer and use it in GitHub Desktop.
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
#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)
@BharathKumarS
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment