New test cases added, rejudging my ACed JAVA solution to TLE

  • 4

    A pretty large test case is added, making my previously ACed JAVA solution TLE.
    I guess it's due to the frequent stack operations (reallocation memory).
    I worked around this by using ArrayList to simulate the Stack and specify the init capacity to avoid memory reallocation. It works.

    Not sure if there is better solution.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.