Skip to content

Commit 3e570a9

Browse files
Update 853-Car-Fleet.py
1 parent 8da3d29 commit 3e570a9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

python/853-Car-Fleet.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
class Solution:
22
def carFleet(self, target: int, position: List[int], speed: List[int]) -> int:
3-
pair = [[p, s] for p, s in zip(position, speed)]
4-
3+
pair = [(p, s) for p, s in zip(position, speed)]
4+
pair.sort(reverse=True)
55
stack = []
6-
for p, s in sorted(pair)[::-1]: # Reverse Sorted Order
6+
for p, s in pair: # Reverse Sorted Order
77
stack.append((target - p) / s)
88
if len(stack) >= 2 and stack[-1] <= stack[-2]:
99
stack.pop()
10-
return len(stack)
10+
return len(stack)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy