Shared Interest π·
Given a graph of friends who have different interests, determine which groups of friends have the most interests in common. Then use a little math to determine a value to return.
The graph will be represented as a series of nodes numbered consecutively from 1 to friends_nodes. Friendships have evolved based on interests which will be represented as weights in the graph. Any members who share the same interest are said to be connected by that interest. Once the node pairs with the maximum number of shared interests are determined, multiply the friends_nodes of the resulting node pairs and return the maximal product.
Complete the function maxShared in the editor.
maxShared has the following parameter(s):
int friends_nodes: number of nodesint friends_from[friends_edges]: the first part of node pairsint friends_to[friends_edges]: the other part of node pairsint friends_weight[friends_edges]: the interests of node pairsReturns
int: maximal integer product of all node pairs sharing the most interests.
1Example 1

friends_nodes of the resulting node pairs: 1 Γ 2 = 2 and 2 Γ 3 = 6.
- The maximal product is 6.Constraints
Limits and guarantees your solution can rely on.
A yet-to-be-unearthed secret π«’