• + 0 comments

    What is the issue with this code? It takes 3.3 seconds in Windows and 1.3 seconds in Mac but Hackerank shows runtime error for 10 mill n elements

    def arrayManipulation(n, queries):

    temp_arr = [0]*(n+1)
    
    for a,d,k in queries:
        temp_arr[a-1] += k
        temp_arr[d] -=k
    
    for i in range(1,n):
        temp_arr[i] += temp_arr[i-1] 
    
    return(max(temp_arr))