开发者

find same node from two single linked list. Can't use hash, Can not be O(n^2) complexity

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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜