#include <iostream> // 前提 :二叉树不具有父节点 如果具有父节点则是 T型链表问题 -> 先走几步的问题。 #include <string> #include <cstring> #include <cstdlib> #include <cstdio> #include <cmath> #include <vector> #include <stack> #include <deque> #include <queue> #include <bitset> #include <list> #include <map> #include <set> #include <iterator> #include <algorithm> #include <functional> #include <utility> #include <sstream> #include <climits> #include <cassert> #define BUG puts("here!!!"); using namespace std; struct Node { int value; Node *lchild, *rchild; }; list<Node*> L1; list<Node*> L2; bool getNodePath(Node* pr, Node* tar, list<Node*>& L) { if(pr == NULL) return false; if(pr == tar) return true; L.push_back(pr); bool flag = false; if(pr->lchild != NULL) flag = getNodePath(pr->lchild, tar, L); if(!flag && pr->rchild) flag = getNodePath(pr->rchild, tar, L); if(!flag) L.pop_back(); return flag; } Node* getCom(const list<Node*>& L1, const list<Node*>& L2) { list<Node*>::const_iterator it1 = L1.begin(); list<Node*>::const_iterator it2 = L2.begin(); Node* pLast = NULL; while(it1 != L1.end() && it2 != L2.end()) { if(*it1 != *it2) break; pLast = *it1; ++it1; ++it2; } return pLast; } int main() { return 0; }