Problem Statement | |||||||||||||
A word is grouped if, for each letter in the word, all occurrences of that letter form exactly one consecutive sequence. In other words, no two equal letters are separated by one or more letters that are different. For example, the words "ccazzzzbb" and "code" are grouped, while "aabbbccb" and "topcoder" are not. You are given several words as a String[]. Return how many of them are grouped. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | words will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element of words will contain between 1 and 50 characters, inclusive. | ||||||||||||
- | Each element of words will contain only lowercase letters ('a' - 'z'). | ||||||||||||
- | All elements of words will be distinct. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|