Why it's Time Limit Exceeded?


  • 0
    D
    This post is deleted!

  • 0
    E
    1. if a pointer is null, it is not false, the following code will still output "Test Pass", instead, use if(head!=NULL)
    head = NULL
    if(head)   // this will output "Test Pass"
      cout << "Test Pass" << endl;
    if(head!=NULL) // this will output nothing
      out << "Test Pass" << endl
    
    1. i think the for part of your program is wrong, you just link the last listNode to the head which will make a circle, not reverse

Log in to reply
 

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