Problem Statement
You are given a String composed of A's and B's. Each A and B denotes a move performed by players A and B, respectively. Return the length of the longest combo performed by either player. A combo is a string of moves executed by a player that is not interrupted by the opposing player (see the examples for further clarification).
Definition
- Class:
- ComboLength
- Method:
- howLong
- Parameters:
- String
- Returns:
- int
- Method signature:
- int howLong(String moves)
- (be sure your method is public)
Constraints
- moves will contain between 2 and 50 characters inclusive.
- Each character of moves will be A or B.
Examples
"AAA"
Returns: 3
Player A executes 3 moves in a row."AAABBBBAA"
Returns: 4
Player A executes 2 combos of length 3 and 2 respectively. Player B executes a single combo of length 4."BBAABBAABBAABBAA"
Returns: 2
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
Returns: 50
"AAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAA"
Returns: 25