Nutanix | OA | Social Distancing
1327

There are N students standing in a line. You are given the first letter of the names for each of them. You need to divide into a maximum number of contiguous subarray such that each student with the same starting letter in their name should be in the same group.

Constraints:
1 <= T <= 10
1 <= N <= 100000

Input format:
The first line of the input contains a single integer T denoting the number of test cases in the file.
Each of the next T lines contains a single string of N characters, where each character is lowercase English alphabet and the starting letter of the student's name.

Output format:
For each test case, output the maximum number of contiguous subarrays.

Sample input:
2
aabbcc
abccabdfed

Sample output:
3
2

Explanation:
aa | bb | cc
abccab | dfed

| above shows the split for the different subarrays

Comments (7)