LCA
WatchLessMobile
这个作者很懒,什么都没留下…
展开
-
1151 LCA in a Binary Tree (30分)
普通二叉树的LCA用二叉搜索树的方法会超时。因为不如二叉搜索树搜索的快。难点:递归,画图理解即可。#include <iostream>#include <algorithm>using namespace std;const int SIZE = 30005;int inOrder[SIZE];int preOrder[SIZE];struct Node { int data; Node* left,* right; Node() {l原创 2020-11-22 20:22:09 · 67 阅读 · 0 评论 -
1143 Lowest Common Ancestor (30分)
#include <iostream>#include <vector>#include <algorithm>using namespace std;const int SIZE = 80000;int postOrder[SIZE];int path[SIZE];int res;struct Node { int data; Node* left, * right; Node() { left = right = NULL; }原创 2020-11-22 15:07:41 · 101 阅读 · 0 评论