We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Array Manipulation
Array Manipulation
Sort by
recency
|
2410 Discussions
|
Please Login in order to post a comment
Hi, I would like to know what is wrong with this implementation because it gives wrong answers for some of the test cases. Maybe if somebody could provide an example were it fails that would be great.
my python3 code but time was exceeded arr=[0]*n for a,b,c in queries: for i in range(a, b + 1): arr[a-1]+=c a+=1 arr.sort(reverse=True) return arr.pop(0)
my python3 code but time was exceeded arr=[0]*n for a,b,c in queries: for i in range(a, b + 1): arr[a-1]+=c a+=1 arr.sort(reverse=True) return arr.pop(0)
Just store the data in a dictionary as below:
As I understand it, the way AI does it is to select pins to store the difference value between the right part and the left part, then use a for loop to find the maximum value after executing the query, which is difficult. explain