并查集的路径压缩. #include <stdio.h> #include <string.h> #define MAXNUM 100005 int deg[MAXNUM], bin[MAXNUM]; char isCycle[MAXNUM]; int find(int x) { int r = x; int i = x, j; while (r != bin[r]) r = bin[r]; while (i != r) { j = bin[i]; bin[i] = r; i =…
[98]Validate Binary Search Tree [99]Recover Binary Search Tree [100]Same Tree [101]Symmetric Tree [104]Maximum Depth of Binary Tree [105]Construct Binary Tree from Preorder and Inorder Traversal [106]Construct Binary Tree from Inorder and Postorder T…
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 2487 Accepted Submission(s): 386 Problem Description In graph theory, the complement of a graph G is a graph H on the same vertices such tha…
[LeetCode]785. Is Graph Bipartite? 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/is-graph-bipartite/description/ 题目描述: Given an undirected graph, return true if and only if it is bipartite. Re…
Connected Graph Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3156 Accepted: 1533 Description An undirected graph is a set V of vertices and a set of E∈{V*V} edges.An undirected graph is connected if and only if for every pair (u,v)…
[题目] Description Harry and Sally were playing games at Christmas Eve. They drew some Christmas trees on a paper: Then they took turns to cut a branch of a tree, and removed the part of the tree which had already not connected with the root. A step sh…