Three nodes that are interconnected form a triple.
A score for a triple can be calculated by counting the total number of nodes outside the triple that are joined with at least one node inside the triple.
Find the minimum triple score in the graph, or return -1 if no triples exist.
Example:
Input:
num_nodes = 5
edges_from = [1, 1, 2, 2, 3, 4]
edges_to = [2, 3, 3, 4, 4, 5]
Output: 2
Explanation:
There are two possible triples: {1,2,3} and {2,3,4}
The score for {1,2,3} is 0 + 1 + 1 = 2.
The score for {2,3,4} is 1 + 1 + 1 = 3.
Return 2
Copyright © A++ Code Bootcamp 2023