Skip to content

Instantly share code, notes, and snippets.

@ShinJJang
Created January 3, 2020 15:32
Show Gist options
  • Save ShinJJang/c6940e7a67b9f8d1a10c3183f462e74b to your computer and use it in GitHub Desktop.
Save ShinJJang/c6940e7a67b9f8d1a10c3183f462e74b to your computer and use it in GitHub Desktop.
def solution(heights):
diff = []
for idx in range(len(heights)-1):
diff.insert(len(diff), heights[idx] - heights[idx+1])
receives = [0]
for idx in range(len(diff)):
recv = 0
for t in range(idx, -1, -1):
if sum(diff[t:idx+1]) > 0:
recv = t + 1
break
receives.append(recv)
return receives
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment