## Description

## Submission

class Solution {
public:
int minTrioDegree(int n, vector<vector<int>>& edges) {
vector<vector<int>> matrix(n+1, vector<int>(n+1, 0));
vector<int> degree(n+1, 0);
for(auto& e: edges) {
matrix[e[0]][e[1]] = 1;
matrix[e[1]][e[0]] = 1;
degree[e[0]]++;
degree[e[1]]++;
}
int ret = INT_MAX;
for(int i = 1; i <= n; ++i) {
for(int j = i + 1; j <= n; ++j) {
if(!matrix[i][j]) continue;
for(int k = j + 1; k <= n; ++k) {
if(matrix[j][k] && matrix[i][k]) {
ret = min(ret, degree[i] + degree[j] + degree[k] - 2 * 3);
}
}
}
}
return ret == INT_MAX ? -1 : ret;
}
};