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
- Discussions
Array Manipulation
Array Manipulation
Sort by
recency
|
25 Discussions
|
Please Login in order to post a comment
Java 8 - This solution does require a sort and then a full pass through the queries, but the memory overhead is less and still meet so the time requirments.
here is hackerrank array manipulation problem solution in Python Java c++ c and javascript
Java
Single Pass O(N) Functional Sol'n
Understand the Difference Array Trick - super simple and effective!
Make arr size n+1 so we can add to end if its the Last item (or ignore)
only Mark the Starts with +query and mark the end+1 index with a -ve value [100, 500 , 0 , 200 , -100 , -500 , 0 , -200 ]
Then simply compute the Prefix Array in a Single Pass