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
|
2504 Discussions
|
Please Login in order to post a comment
Mi solución en Python 3:
First solution: Populate the main array with the final values and then calculate the max:
Second solution: While computing the running sum, we track the maximum value encountered.That maximum is the final answer. We save on some space by using this solution.
`
We use a helper array, called diff, to efficiently track the range updates.
For each operation (a, b, k):
So we perform:
I'll post the solution in the following posts:
After processing all operations, we traverse the diff array from left to right while maintaining a running sum. The final value at each index is obtained by adding the current value in diff to the running sum of all previous values.
this task has so many flows in its wording that I even dont know where to start. The only difuclty of the task is simply guessing what the aim is. I suspect you can pass it in secons with one assumtion: you have seen it before and you know already what it really means. This would never be an acceptable official exam type question or would be discared after the first trial.
Here's my adopted solution for Golang, credits to mwwhite