Class Solution
java.lang.Object
g1701_1800.s1761_minimum_degree_of_a_connected_trio_in_a_graph.Solution
1761 - Minimum Degree of a Connected Trio in a Graph.<p>Hard</p>
<p>You are given an undirected graph. You are given an integer <code>n</code> which is the number of nodes in the graph and an array <code>edges</code>, where each <code>edges[i] = [u<sub>i</sub>, v<sub>i</sub>]</code> indicates that there is an undirected edge between <code>u<sub>i</sub></code> and <code>v<sub>i</sub></code>.</p>
<p>A <strong>connected trio</strong> is a set of <strong>three</strong> nodes where there is an edge between <strong>every</strong> pair of them.</p>
<p>The <strong>degree of a connected trio</strong> is the number of edges where one endpoint is in the trio, and the other is not.</p>
<p>Return <em>the <strong>minimum</strong> degree of a connected trio in the graph, or</em> <code>-1</code> <em>if the graph has no connected trios.</em></p>
<p><strong>Example 1:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/01/26/trios1.png" alt="" /></p>
<p><strong>Input:</strong> n = 6, edges = [[1,2],[1,3],[3,2],[4,1],[5,2],[3,6]]</p>
<p><strong>Output:</strong> 3</p>
<p><strong>Explanation:</strong> There is exactly one trio, which is [1,2,3]. The edges that form its degree are bolded in the figure above.</p>
<p><strong>Example 2:</strong></p>
<p><img src="https://assets.leetcode.com/uploads/2021/01/26/trios2.png" alt="" /></p>
<p><strong>Input:</strong> n = 7, edges = [[1,3],[4,1],[4,3],[2,5],[5,6],[6,7],[7,5],[2,6]]</p>
<p><strong>Output:</strong> 0</p>
<p><strong>Explanation:</strong> There are exactly three trios:</p>
<ol>
<li>
<p>[1,4,3] with degree 0.</p>
</li>
<li>
<p>[2,5,6] with degree 2.</p>
</li>
<li>
<p>[5,6,7] with degree 2.</p>
</li>
</ol>
<p><strong>Constraints:</strong></p>
<ul>
<li><code>2 <= n <= 400</code></li>
<li><code>edges[i].length == 2</code></li>
<li><code>1 <= edges.length <= n * (n-1) / 2</code></li>
<li><code>1 <= u<sub>i</sub>, v<sub>i</sub> <= n</code></li>
<li><code>u<sub>i</sub> != v<sub>i</sub></code></li>
<li>There are no repeated edges.</li>
</ul>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
minTrioDegree
public int minTrioDegree(int n, int[][] edges)
-