Influencer Collaboration Group
MediumGraph · TikTok
Each entry of creators is [name, followers]. Each entry of collaborations is [name1, name2], an undirected link between two creators. Two creators are in the same group if they are connected through a chain of collaborations; a creator with no collaborations is a group of one.
A group's total is the sum of its members' followers. Among groups whose total is at least minimum_followers, return the group with the largest total, as a list of member names sorted ascending.
- If several qualifying groups tie on the total, return the one whose sorted name list is lexicographically smallest (compare the lists element by element, like Python list comparison).
- If no group qualifies, return
[]. - Collaborations that mention a name not in
creatorsare ignored. A collaboration may be listed more than once.
Example 1
- Input:
- creators = [["mia", 40], ["leo", 25], ["ava", 30], ["zed", 70], ["kai", 5]], collaborations = [["mia", "leo"], ["leo", "kai"]], minimum_followers = 50
- Output:
- ["kai", "leo", "mia"]
- Explanation
- The groups are
{mia, leo, kai}with 40 + 25 + 5 = 70,{ava}with 30, and{zed}with 70. Both 70s clear the minimum and tie, so the lexicographically smaller sorted list["kai", "leo", "mia"]wins over["zed"].
Example 2
- Input:
- creators = [["a", 10], ["b", 20], ["c", 15]], collaborations = [["a", "x"], ["b", "c"]], minimum_followers = 40
- Output:
- []
- Explanation
"x"is unknown, so that link is ignored. The groups total 10 (a) and 35 (b,c), and neither reaches 40.
Example 3
- Input:
- creators = [["ray", 8], ["sue", 9], ["tom", 3]], collaborations = [["tom", "ray"]], minimum_followers = 0
- Output:
- ["ray", "tom"]
- Explanation
{ray, tom}totals 11 and{sue}totals 9. Both qualify with a minimum of 0, and 11 is larger.
Constraints
0 <= creators.length <= 10^50 <= collaborations.length <= 10^5- Creator names are unique, non-empty strings
0 <= followers <= 10^6and0 <= minimum_followers <= 10^11