今日
导:This girl comes from Shan Xi.
我:嗯
导:Is it the province of Xi An?
我:不 西安是Shǎn Xi 的省会
导:So, where does this girl come from?
我:Shān Xi
导:So, it is the province of Xi An?
我:不 西安是Shǎn Xi 的省会 这个女孩是Shān Xi 人
导: Are you crazy?
我:...你没听出来Shǎn Xi和Shān Xi的区别吗
导:They are the same. It is like you are saying Tromsø is not Tromsø
我:...(你忘了你放弃学中文的原因了吗
导:This girl comes from Shan Xi.
我:嗯
导:Is it the province of Xi An?
我:不 西安是Shǎn Xi 的省会
导:So, where does this girl come from?
我:Shān Xi
导:So, it is the province of Xi An?
我:不 西安是Shǎn Xi 的省会 这个女孩是Shān Xi 人
导: Are you crazy?
我:...你没听出来Shǎn Xi和Shān Xi的区别吗
导:They are the same. It is like you are saying Tromsø is not Tromsø
我:...(你忘了你放弃学中文的原因了吗
Xi 'an is one of the four ancient capitals in the world, as well as one of the capitals with the most dynasties, the longest time and the greatest influence in Chinese history.
Tiger symbol fully demonstrate the high cultural and political influence of Xi 'an.
Thirteen dynasties in Chinese history established their capitals here: western Zhou, Qin, Western Han, Xin Dynasty, Eastern Han, Western Jin, Former Zhao, former Qin, Post-Qin, Western Wei, Northern Zhou, Sui and Tang.
Tiger symbol fully demonstrate the high cultural and political influence of Xi 'an.
Thirteen dynasties in Chinese history established their capitals here: western Zhou, Qin, Western Han, Xin Dynasty, Eastern Han, Western Jin, Former Zhao, former Qin, Post-Qin, Western Wei, Northern Zhou, Sui and Tang.
1719. Number Of Ways To Reconstruct A Tree
You are given an array pairs, where pairs[i] = [xi, yi], and:
There are no duplicates.
xi < yi
Let ways be the number of rooted trees that satisfy the following conditions:
The tree consists of nodes whose values appeared in pairs.
A pair [xi, yi] exists in pairs if and only if xi is an ancestor of yi or yi is an ancestor of xi.
Note: the tree does not have to be a binary tree.
Two ways are considered to be different if there is at least one node that has different parents in both ways.
Return:
0 if ways == 0
1 if ways == 1
2 if ways > 1
A rooted tree is a tree that has a single root node, and all edges are oriented to be outgoing from the root.
An ancestor of a node is any node on the path from the root to that node (excluding the node itself). The root has no ancestors.
解题重点:
1. 题目的意思是,pairs如果能构成树,那pairs的结对和树拆散后要一致,不能有多余的节点。
2. 通过假设pairs能构成树,找到一些规律,或者推论。节点总数为n,节点 x 的祖先和后代的节点集合表示 adj[x]
3. 根结点为root, 有adj[root]的数量为n-1
4. 如果x为y的祖先,则有len(adj[x]) >= len(adj[y]),adj[y]是adj[x]的子集。
5. 如果x为y的祖先,且adj[xi]=adj[yi],则此时构成树的方案数一定不是唯一的。
6.找父节点,依次跟父节点对比。父节点:节点 x 满足 len(adj[x])最小且 len(adj[x])>= len(ajd[node])。判断子集关系,判断节点数量,相等则有多种可能。
You are given an array pairs, where pairs[i] = [xi, yi], and:
There are no duplicates.
xi < yi
Let ways be the number of rooted trees that satisfy the following conditions:
The tree consists of nodes whose values appeared in pairs.
A pair [xi, yi] exists in pairs if and only if xi is an ancestor of yi or yi is an ancestor of xi.
Note: the tree does not have to be a binary tree.
Two ways are considered to be different if there is at least one node that has different parents in both ways.
Return:
0 if ways == 0
1 if ways == 1
2 if ways > 1
A rooted tree is a tree that has a single root node, and all edges are oriented to be outgoing from the root.
An ancestor of a node is any node on the path from the root to that node (excluding the node itself). The root has no ancestors.
解题重点:
1. 题目的意思是,pairs如果能构成树,那pairs的结对和树拆散后要一致,不能有多余的节点。
2. 通过假设pairs能构成树,找到一些规律,或者推论。节点总数为n,节点 x 的祖先和后代的节点集合表示 adj[x]
3. 根结点为root, 有adj[root]的数量为n-1
4. 如果x为y的祖先,则有len(adj[x]) >= len(adj[y]),adj[y]是adj[x]的子集。
5. 如果x为y的祖先,且adj[xi]=adj[yi],则此时构成树的方案数一定不是唯一的。
6.找父节点,依次跟父节点对比。父节点:节点 x 满足 len(adj[x])最小且 len(adj[x])>= len(ajd[node])。判断子集关系,判断节点数量,相等则有多种可能。
✋热门推荐