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 String results with the results of the last several games a team has played, determine how many of their most recent games to consider to find the team's worst and best percentages of winning. Return a int[] with 2 elements. The first element should be how many of the team's most recent games to consider to give their best winning record (5, in the above example). The second element should be how many of the team's most recent games to consider to give their worst winning record (20, in the above example).
The String results will contain only the characters 'W' and 'L', where 'W' indicates a win, and 'L' indicates a loss. The left-most character represents the most recent game, and the right-most character represents the least recent game. The string for the example above would be
"WWWWWLLLLLLLLLLLLLLL".
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.
|