The judge ridiculously checks the linked list, which results in Time Limit Exceed

  • 2

    It seems the system checks the linked list when judging the answer. If there is a loop in the list, there will be a Time Limit Exceed error.

    For example, if you reverse the second half of the list a=>b=>c=>NULL, there will be two result:

    1. a-->b--><--c (b's next is c and c's next is b)
    2. a-->b-->NULL and c-->b-->NULL (b's next is NULL while a,c's next is b)

    Note that, the first result does not prevent you from getting a correct result, as long as you record the length of the original list and know where the mid point is, and stop checking at mid point.

    However, the code will have Time Limit Exceed error if you build a list like 1, though your answer is right. This is really misleading.

Log in to reply

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