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.
Even with this, it was insufficiently fast for me and failed on 14.
The optimization that allowed this method to pass for me was to preinitialize the array. This saves on perhaps many memory operations that would be used to extend the array.
That said, myself I don't quite know what principle it is that allows us to know which prefix to search for based on the current one.
Maximum Subarray Sum
You are viewing a single comment's thread. Return to all comments →
it doesn't pass 16th test case.
I passed using the solution on Python3. Maybe you can try using the same code and submit it on Pypy3. It is usually faster than on Python3.
Even with this, it was insufficiently fast for me and failed on 14.
The optimization that allowed this method to pass for me was to preinitialize the array. This saves on perhaps many memory operations that would be used to extend the array.
That said, myself I don't quite know what principle it is that allows us to know which prefix to search for based on the current one.