标签:tco class lis tar solution col bsp min leetcode
1 class Solution: 2 def distanceBetweenBusStops(self, distance: List[int], start: int, destination: int) -> int: 3 if start == destination: 4 return 0 5 elif start < destination: 6 dis1,dis2 = 0,0 7 for i in range(start,destination): 8 dis1 += distance[i] 9 for i in range(start): 10 dis2 += distance[i] 11 for j in range(len(distance)-1,destination-1,-1): 12 dis2 += distance[j] 13 return min(dis1,dis2) 14 else: 15 dis1,dis2 = 0,0 16 start,destination = destination,start 17 for i in range(start,destination): 18 dis1 += distance[i] 19 for i in range(start): 20 dis2 += distance[i] 21 for j in range(len(distance)-1,destination-1,-1): 22 dis2 += distance[j] 23 return min(dis1,dis2)
标签:tco class lis tar solution col bsp min leetcode
原文地址:https://www.cnblogs.com/asenyang/p/11504143.html