You are viewing a single comment's thread. Return to all 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))
There is nothing wrong I can find. I believe it is correct. The runtime error may come from max(10 milliion length of array) which times out.
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Array Manipulation
You are viewing a single comment's thread. Return to all 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):
There is nothing wrong I can find. I believe it is correct. The runtime error may come from max(10 milliion length of array) which times out.