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.
input1: N, denoting the number of students.
input2: An array of N elements where the ith element denotes the
compatibility factor of th student.
Your function should return the maximum number of groups that can be
Input 1: 2
Only 1 group exists which consists of first 2 students.
The following 3 groups can be formed