#include <leetcode.h>
|
static int | checkWays (vector< vector< int > > &pairs) |
|
◆ checkWays()
int leetcode::number_of_ways_to_reconstruct_a_tree::Solution::checkWays |
( |
vector< vector< int > > & |
pairs | ) |
|
|
static |
在文件 leetcode.cpp 第 2957 行定义.
2958 unordered_map<int, unordered_set<int>> adj;
2959 for(
auto &p: pairs) {
2960 adj[p[0]].emplace(p[1]);
2961 adj[p[1]].emplace(p[0]);
2965 for(
auto &[node, neighbours]: adj) {
2966 if(neighbours.size() == adj.size() - 1) {
2976 for(
auto &[node, neighbours]: adj) {
2980 const int currDegree = neighbours.size();
2982 int parentDegree = INT_MAX;
2985 for(
const auto &neighbour: neighbours) {
2986 if(adj[neighbour].size() < parentDegree && adj[neighbour].size() >= currDegree) {
2988 parentDegree = adj[neighbour].size();
2996 for(
const auto &neighbour: neighbours) {
2997 if(neighbour == parent) {
3000 if(
static_cast<unsigned int>(adj[parent].contains(neighbour)) == 0U) {
3004 if(parentDegree == currDegree) {
引用了 acwing::acwing836_408::root.
被这些函数引用 leetcode::number_of_ways_to_reconstruct_a_tree::TEST().
该类的文档由以下文件生成: