We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
def arrayManipulation(n, queries):
arr=[0]*n
for _ in queries:
start=[0]-1
end=[1]-1
val=_[2]
topVal=end+1
for i in range(start,topVal):
arr[i]+=val
return max(arr)
m = input().split()
n = int(nm[0])
m = int(nm[1])
queries = []
for _ in range(m):
queries.append(list(map(int, input().rstrip().split())))
result=arrayManipulation(n, queries)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Array Manipulation
You are viewing a single comment's thread. Return to all comments →
def arrayManipulation(n, queries): arr=[0]*n for _ in queries: start=[0]-1 end=[1]-1 val=_[2] topVal=end+1 for i in range(start,topVal): arr[i]+=val return max(arr)
m = input().split()
n = int(nm[0])
m = int(nm[1])
queries = []
for _ in range(m): queries.append(list(map(int, input().rstrip().split())))
result=arrayManipulation(n, queries)