this method may cost a lot of time


  • 0
    W

    Re: Simple C++ solution (5 lines)
    i think this method will make the code concise, but this code may spend much more time to run when two lists have no interactions. For example, if the first list's length is m, the second's is n, m and n are relatively prime. Then for this algorithm this will cost O(m*n) to find out. However, if we use the tails of each lists to find out, it will only takes O(p) (p =max(m, n)).


Log in to reply
 

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