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 th student.
Output Specification:
Your function should return the maximum number of groups that can be
created.
Example 1:
Input 1: 2
Input 2:{1,1}
Output: 1
Explanation:
Only 1 group exists which consists of first 2 students.
Example 2:
input1: 8
input2: (1,2,1,1,1,1,1,1)
Output: 3
Explanation:
The following 3 groups can be formed
(1,2,1)
(1,1)
(1,1,1)