3 ms·
The equivalent Python code works fine, though. >>> a=[0]*sum(rls) >>> sum=-1 >>> for i in rls: ... sum += i ... a[sum] = 1 ...
by toxik 8y ago
The equivalent Python code works fine, though.
>>> a=[0]*sum(rls)
>>> sum=-1
>>> for i in rls:
... sum += i
... a[sum] = 1
...
>>> a.sort()
>>>
Takes a real good while, too.
- iCannotEven 8y agoThat's because the array to be sorted is packed and inflated, so as to be the worst possible input for that kind of sort. Worst-case complexity. Also, I needed to bump my JVM heap up to 16GB (not 9GB as recommended), just to run it.