今天去微软面试,微软出了一道这样的题目.
请问有没有好的算法..
There are 2 singlelinks.
And there might be crossusage in the links.
Please try to program to identify whether there are nodes used by both singlelinks.
e.g.: (for following node, use (next node address, value) style)
Single Node1:
(0FF00AA, 3)->(0DE3AB2, 7)->(037BFAE, 9)->(NULL, 8)
Single Node2:
(07733A3, 7)->(037BFAE,3)->(NULL, 8)
so, in this sample, from the last node (NULL, 8), the singlelink begin cross linked.
So, our target is to verify whether there are cross linked condition in given 2 singlelinks.
Consider the data structure in C# is hard to implement the singlelink,
This question should be implemented in C++ or C.