A group of Gryffindors are playing a variant of Exploding Snap. Each player gets to play a sequence of cards. They can continue playing until one of their cards explodes, at which point the next person gets a turn. The winner is the person who plays the most cards in a row.
A single string can be used to represent this game: each player is represented by a distinct letter or digit, and the string represents the sequence in which players played their cards. For example, “aaabba” means that player “a” played three cards in a row, and then player “b” played two cards and then “a” played one card.
Hermione is looking for a strategy in this game. In particular, she’s interested in how many cards in a row it takes to win. Write a program that takes in a game string and outputs the number of cards that it took to win in that game. In the above example, the number of cards to win is three
A single string can be used to represent this game: each player is represented by a distinct letter or digit, and the string represents the sequence in which players played their cards. For example, “aaabba” means that player “a” played three cards in a row, and then player “b” played two cards and then “a” played one card.
Hermione is looking for a strategy in this game. In particular, she’s interested in how many cards in a row it takes to win. Write a program that takes in a game string and outputs the number of cards that it took to win in that game. In the above example, the number of cards to win is three
Input Format
The first line contains an integer n representing the length of the string s. The second line contains s.
Sample Input
3
aab
Output Format Print a single integer representing the highest number of cards in a row played by any player.
Sample Output
2
You must be logged in to submit a solution.