-1

I was trying to solve a data structure question from Hackerrank and i could not figure it out. Actually, i could not understand exact logic lying under problem.Below is a link to question question.

https://www.hackerrank.com/challenges/crush

1 Answers1

0

This is not optmized, so will not pass all tests cases for python (10s timenout), but you can have an idea.

n, m = map(int, raw_input().strip().split(' '))
numbers = []
for i in range(m+1):
    numbers.append(0)

for i in range(m):
    a , b , k = map(int, raw_input().strip().split(' '))
    for j in range(b - a + 1):
        numbers[a + j -1] = numbers[a + j - 1] + k

print(max(numbers))
Samuel Teixeira
  • 326
  • 2
  • 9