1761. Minimum Degree of a Connected Trio in a Graph Hard
1/**
2 * [1761] Minimum Degree of a Connected Trio in a Graph
3 *
4 * You are given an undirected graph. You are given an integer n which is the number of nodes in the graph and an array edges, where each edges[i] = [ui, vi] indicates that there is an undirected edge between ui and vi.
5 * A connected trio is a set of three nodes where there is an edge between every pair of them.
6 * The degree of a connected trio is the number of edges where one endpoint is in the trio, and the other is not.
7 * Return the minimum degree of a connected trio in the graph, or -1 if the graph has no connected trios.
8 *
9 * Example 1:
10 * <img alt="" src="https://assets.leetcode.com/uploads/2021/01/26/trios1.png" style="width: 388px; height: 164px;" />
11 * Input: n = 6, edges = [[1,2],[1,3],[3,2],[4,1],[5,2],[3,6]]
12 * Output: 3
13 * Explanation: There is exactly one trio, which is [1,2,3]. The edges that form its degree are bolded in the figure above.
14 *
15 * Example 2:
16 * <img alt="" src="https://assets.leetcode.com/uploads/2021/01/26/trios2.png" style="width: 388px; height: 164px;" />
17 * Input: n = 7, edges = [[1,3],[4,1],[4,3],[2,5],[5,6],[6,7],[7,5],[2,6]]
18 * Output: 0
19 * Explanation: There are exactly three trios:
20 * 1) [1,4,3] with degree 0.
21 * 2) [2,5,6] with degree 2.
22 * 3) [5,6,7] with degree 2.
23 *
24 *
25 * Constraints:
26 *
27 * 2 <= n <= 400
28 * edges[i].length == 2
29 * 1 <= edges.length <= n * (n-1) / 2
30 * 1 <= ui, vi <= n
31 * ui != vi
32 * There are no repeated edges.
33 *
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/minimum-degree-of-a-connected-trio-in-a-graph/
38// discuss: https://leetcode.com/problems/minimum-degree-of-a-connected-trio-in-a-graph/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43 pub fn min_trio_degree(n: i32, edges: Vec<Vec<i32>>) -> i32 {
44 0
45 }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_1761() {
56 }
57}
58
Back
© 2025 bowen.ge All Rights Reserved.