Problem Statement
If a baseball team loses 15 games in a row, and then wins its next 5, there are a number of ways this could be reported. A fan of the team could brag that they have won all 5 of their last 5 games. However, it could also be truthfully said that they have won 5 out of their last 10 games, or only 25% of their last 20 games.
Given a
The
Never consider fewer than 3 games. When considering 7 games (for example), they must be the 7 most recent games, not any 7 from the list. If different numbers of games give the same winning record, choose the larger number of games.
Definition
- Class:
- WinningRecord
- Method:
- getBestAndWorst
- Parameters:
- String
- Returns:
- int[]
- Method signature:
- int[] getBestAndWorst(String games)
- (be sure your method is public)
Constraints
- results will contain between 3 and 50 characters, inclusive.
- Each character of results will be either 'W' or 'L'.
Examples
"WWWWWLLLLLLLLLLLLLLL"
Returns: { 5, 20 }
This is the example from the problem statement.
"WWWWWW"
Returns: { 6, 6 }
No matter how many games you consider, the team's winning record is 100% and the losing record is 0%.
"LWLWLWLWLWLWLWLWLWLWLWLWLWLWLWLWLWLWLWLWLWLWLWLWLW"
Returns: { 50, 3 }
"WLWLWLLWWLWLWWWWWWWLWLLLLLLLLLLLLWWLWLLWWWLLLWLWLW"
Returns: { 19, 33 }
"LWWLWWLWWLLLW"
Returns: { 9, 12 }
"WWW"
Returns: { 3, 3 }
"LLL"
Returns: { 3, 3 }
"WLW"
Returns: { 3, 3 }
"LWL"
Returns: { 3, 3 }
"WWWL"
Returns: { 3, 4 }
"LLLW"
Returns: { 4, 3 }
"WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW"
Returns: { 50, 50 }
"LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL"
Returns: { 50, 50 }
"WWWWWWLWWWWWWLWWWWWWLWWWWWWLWWWWWWLWWWWWWLWWWWWWLW"
Returns: { 6, 49 }
"WLWLLWLLLWLLLLWLLLLLWLLLLLLWLLLLLLLWLLLLLLLLWLLLL"
Returns: { 3, 44 }
"LWWLWWWLWWLLWWLWLWLWLLWLLLLWWLWLWWLLLWWLWLWLLWLWLW"
Returns: { 7, 27 }
"LWLLLWLWLLLWWLWLWLWLWLLWLLLLLWWWLWWLLLWLLWLLWWLLWW"
Returns: { 35, 5 }
"WLWWLLLWWWWLWWLLWWWLLWLWLWWWWWWLLLLWLLLLLWWWWLWLLW"
Returns: { 4, 7 }
"LWWWWWWLLWWWWWLWLWWLLWLWLWLLLWLWLLLLLWLWLLWWLWLWWL"
Returns: { 7, 42 }
"WWLLWWWWLWWLWWWLLWWWWWWWLWLWLLLWWWWWWWLWWWWWWWWLLW"
Returns: { 24, 4 }
"LWWWWWWLLWWLWWWWWWLLLLLLLLWWLLWWLLLWLLLWWLWWWWLWWW"
Returns: { 7, 39 }
"LWWLWWLWWLLLW"
Returns: { 9, 12 }
"WWLLLLLL"
Returns: { 3, 8 }
"LLWWWWWWWW"
Returns: { 10, 3 }
"WLWLWLLWWLWLWWWWWWWLWLLLLLLLLLLLLWWLWLLWWWLLLWLWLW"
Returns: { 19, 33 }
"LLLLLLLLLLLL"
Returns: { 12, 12 }
"WWL"
Returns: { 3, 3 }
"WLL"
Returns: { 3, 3 }
"WWLLL"
Returns: { 3, 5 }
"LLLLLLLLLLLLL"
Returns: { 13, 13 }
"LLL"
Returns: { 3, 3 }
"WWWWWLLLLLLLLLLLLLLL"
Returns: { 5, 20 }
"LWLWLWLWLWLWLWLWLWLWLWLWLWLWLWLWLWLWLWLWLWLWLWLWLW"
Returns: { 50, 3 }
"WWLL"
Returns: { 3, 4 }
"WWLLLLLLLLLLLLL"
Returns: { 3, 15 }
"WWLW"
Returns: { 4, 3 }
"WLLLLLL"
Returns: { 3, 7 }
"WWWWWW"
Returns: { 6, 6 }
"WLLLL"
Returns: { 3, 5 }
"LLLLLLWLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLWWWWWW"
Returns: { 7, 6 }
"LLLLLLLLL"
Returns: { 9, 9 }