Maximum Subarray Sum

  • + 2 comments

    it doesn't pass 16th test case.

    • + 1 comment

      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.

      • + 0 comments

        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.