2 ms·
I presume you mean allocating new memory. You could sum an array and keep track of state/store cumulative sum in the existing array i.e. in-place algorithmic ap
by Frost1x 6y ago
I presume you mean allocating new memory. You could sum an array and keep track of state/store cumulative sum in the existing array i.e. in-place algorithmic approaches:
https://en.m.wikipedia.org/wiki/In-place_algorithm https://en.m.wikipedia.org/wiki/In-place_algorithm
You still have to have memory and use it though, somewhere.
- aliceryhl 6y agoYes of course. If the algorithm operates on existing allocations, then it doesn't allocate any memory. Similarly the algorithm might operate on a fixed set of integers, which would not require allocations at all, even in Java.