Weighted union search set

A basic union search set There are only two operations for the basic union query set, one is to find ancestors, and the other is to merge int find(int x) { if(x==pre[x]) return x; else return pre[x]=find(pre[x]); } void join(int x,int y) { pre[find(x)]=find(y); } Two weighted union search set   for weighted concurrent sear ...

Posted by Stevis2002 on Wed, 03 Nov 2021 12:48:17 -0700

Leetcode 785. Judgment bipartite graph (medium)

subject There is an undirected graph with n nodes. Each of these nodes has a unique number between 0 and n - 1. Give you a two-dimensional array graph, where graph[u] is an array of nodes, which is composed of adjacent nodes of node U. Formally, for each V in graph[u], there is an undirected edge between node u and node v. The undirected graph ...

Posted by proxydude on Fri, 15 Oct 2021 20:10:23 -0700