ComboLength
SRM 234 · 2005-03-16 · by AdminBrett
SRM 234 · 2005-03-16 · by AdminBrett · Simple Search, Iteration
Problem Statement
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).
Constraints
- moves will contain between 2 and 50 characters inclusive.
- Each character of moves will be A or B.
Examples
0)
"AAA" Returns: 3
Player A executes 3 moves in a row.
1)
"AAABBBBAA" Returns: 4
Player A executes 2 combos of length 3 and 2 respectively. Player B executes a single combo of length 4.
2)
"BBAABBAABBAABBAA" Returns: 2
3)
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" Returns: 50
4)
"AAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAA" Returns: 25
Submissions are judged against all 32 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class ComboLength with a public method int howLong(string moves) · 32 test cases · 2 s / 256 MB per case