• + 1 comment

    Brilliant man, mine was working for initial test cases but getting timeout for rest.

    def arrayManipulation(n, queries):
        a = [0]*(n +1)
        z=[]
        for i in queries:
            z.append(i)
        for i in range(len(z)):
            for j in range(int(z[i][0]),int( z[i][1])+1):
                a[j] = a[j]+int ( z[i][2])
        return max(a)
    
    • + 0 comments

      Hi,

      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.

      https://youtu.be/hDhf04AJIRs

      Would really appreciate your feedback like, dislike , comment etc. on my video.