find same node from two single linked lists. Can't use hash, Can not be O(n^2) complexity.
Please开发者_JS百科 give some hints. thank you so much.
Sort the two linked lists and then do a linear pass to find two nodes that are equal. This is 2*O(NlogN) + 2*O(N) = O(NlogN).
精彩评论