Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ programme There are friends_nodes friends, numb 1 to friends nodes, who like to eat Open with different candies. There are friends

 

Write a C++ programme There are friends_nodes friends, numb 1 to friends nodes, who like to eat Open with different candies. There are friends gan pairs of friends where each pair of friends is connected by the common candy that they both like. Candies are numbered from 1 to 100. Note that if x[i] and y[i] are connected by a candy c[i] and y[i] and z[i] are also connected by the candy c[i], then x[i] and z[i] are also said to be connected by c[i]. Find the maximal product of x[i] and y[i] so that x[i] and y[i] share the largest group of friends which is connected by some common candy. As an example, assume the following 6 inputs: From To Candy 2 51 3 51 6 51 8 51 9 51 3 51 1 7 5 10 6 2 Everyone likes the same candy, but not everyone is connected. A graphical representation is: The largest group is [1, 2, 3, 7] and its largest elements are 3 and 7. Their product is 21. Function Description Complete the function countCandies in the editor below. The function must return an integer that represents to page dunt of the maximumovo frend numbers in the largest group. countCandies has the following parameter(s): friends_nodes: an integer, the number of friends friends from[friends_from[0],...friends_from[n-1]]: an integer array where each element denotes the first friend in the pair friends_to[friends_to[0]....friends_to[n-1]]: an integer array where each element denotes the second friend in the pair friends_weight[friends_weight[0]....friends_weight[n-1]]: an integer array where each element denotes a candy liked by both friends Constraints 2 friends_nodes 100 1 s friends_edges s min (200, 1 friends_weight[i] 100 1 s friends_from[i], friends_to[i] friends_nodes 1s friends_weight[i] friends_edges friends from[i]#friends_to[i] Each pair of friends can be connected by more than one type of candy +

Step by Step Solution

3.57 Rating (157 Votes )

There are 3 Steps involved in it

Step: 1

NOTE Since the programming language is not mentioned below code is written in python language Start ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

If [x] denotes the greatest integer function, find lim x x/[x].

Answered: 1 week ago

Question

Which of the tohowing in trie Which of the tohowing in trie

Answered: 1 week ago