Created
November 4, 2019 21:57
-
-
Save imedadel/03e91f5ce392a652185f3364a24a6cd7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def carParkingRoof(cars, k): | |
if k == 1: return 1 | |
cars.sort() | |
roof = cars[-1]-cars[0]+1 | |
if k == len(cars): return roof | |
for car in range(k-1, len(cars)): | |
roof = min(roof, cars[car] - cars[car-k+1] + 1) | |
return roof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment