Created
July 20, 2021 08:32
-
-
Save goish135/7325ada18f6a22279653a8e30a52b81e to your computer and use it in GitHub Desktop.
This file contains 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
# 370. Range addition | |
updates = [[1,3,2],[2,4,3],[0,2,-2]] | |
length = 5 | |
# [-2,0,3,5,3] | |
initial_arr = [0]*length | |
for i in updates: | |
#print(i) | |
s,d,inc = i[0],i[1],i[2] | |
print(s,d,inc) | |
for j in range(s,d+1): | |
initial_arr[j]+=inc | |
print("result:",initial_arr) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment