Computer Science, asked by krishnamurthy68, 6 days ago

Question :
Picnic A school is organizing a picnic for all its students. There is a total of N students labeled from 1 to N in the school. Each student i has a compatibility factor of Xi.
It is time for the picnic and all students to stand in a line. The student line is to be split into groups. A set of consecutive students standing in a line can form a group. For the picnic to be safe, each group must have at least 2 students with the same compatibility factor.
Finding the maximum number of groups that can be created​

Answers

Answered by prachivaidya3008
21

Explanation:

How to attempt?

Question:

Picnic

A school is organizing a picnic for all its students. There is a total of N students labeled from 1 to N in the school. Each student i has a compatibility factor of Xi.

It is time for the picnic and all students to stand in a line. The student line is to be split into groups. A set of consecutive students standing in a line can form a group. For the picnic to be safe, each group must have at least 2 students with the same compatibility factor.

Finding the maximum number of groups that can be created.

Input Specification:

input1: N, denoting the number of students.

input2: An array of N elements where the ith element denotes the compatibility factor of ith student.

Output Specification:

Your function should return the maximum number of groups that can be created.

Shivani Marotrao Vaic

Answered by bholamohit1998
3

Answer:

Grouping

Explanation:

Group them according to the factor

Similar questions