A question about TLE


  • 0
    Y

    I just found that a minor change in the code will trigger LTE. Is this expected?


  • 0
    S

    What is the minor change?


  • 0
    Y

    When using a hash table, if we add the following code before directly increment count words[L[i]] (i.e., words[L[i]]++), it will trigger TLE. This makes me feel that the timeout value is sophisticatedly set based on the testing code (which should be a working solution), rather than based on time complexity. Anyway, I have to admit time complexity might be difficult to measure in practice.

            if (words.find(L[i]) == words.end()) {
                words[L[i]] = 0;
            }
    

Log in to reply
 

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