You are viewing a single comment's thread. Return to all comments →
n, m = input().strip().split(' ')
n, m = [int(n), int(m)]
l =  * (n+1)
for a0 in range(m):
a, b, k = input().strip().split(' ')
a, b, k = [int(a), int(b), int(k)]
l[a:b+1] = list(map(lambda x:x+k,l[a:b+1]))
The above code is showing runtime error for test case 7 onwards. please suggest the reason?
I experience the same issue. If I run test case 13 locally, my code passes, but if I try the same code remotely on HR, cases 7 -> 13 all fail. Out of memory ?
why deleted :(
Most of the peope solved this problem but time complexity of solution is O(n*m) (due to two nested for loops)which can not be used to solve this problem for given time constraint, so you need better approach which beats O(n*m)
I have created a video tutorial for you and uploaded the same on youtube with complete explanation along with code complexity analysis.
Here is the video tutorial for my solution O(n+m) complexity passed all test cases.
Would really appreciate your feedback like, dislike , comment etc. on my video.
I too tried the same approach. Yes, It's giving runtime error.