标签:weak blog contains style label form targe get return
Given n
nodes in a graph labeled from 1
to n
. There is no edges in the graph at beginning.
You need to support the following method:
1. connect(a, b)
, add an edge to connect node a
and node b. 2.
query(a, b)`, check if two nodes are connected
Example
5 // n = 5 query(1, 2) return false connect(1, 2) query(1, 3) return false connect(2, 4) query(1, 4) return true
标签:weak blog contains style label form targe get return
原文地址:http://www.cnblogs.com/lz87/p/7500092.html