i***0 发帖数: 8469 | 1 how to do it ?=======Problem – coding in c++
I have two node pointer which may be in same link list or not.
The function should return me pointer where they are merging if they are
merging.
If the node pointers are not merging, it should return null pointer. | j********r 发帖数: 21 | 2 Your problem is not well-defined nor described. Here are some hints ...
Assume the lists are not cicular. p and s are two pointers in lists.
If p and s are in the same list, one must be behind the other. If not, they
will never find (meet) each other by tracking down the lists.
Assume p is behind s, so use s traces down the list to check for p. vice
verse.
Similar techniques can be applied to cicular cases. |
|