In Major League Baseball, there is a regular season of games where teams play each other, and at the end of the season, the teams with the best records go on to compete in the playoffs. Better records are indicated by more wins. For this problem, we'll assume that the teams which go to the playoffs are the teams with the best records, and that there are no division champion berths.
During the regular season, it is possible for a team to "clinch" a spot in the playoffs by getting enough wins such that no matter what happens in the remaining games, the team makes the playoffs. Similarly, it is also possible for a team to be eliminated from the playoffs if its record is so poor that no matter what happens, it cannot claim a playoff spot. If it is possible for two or more teams to end in a tied record, and the record is good enough to claim at least one playoff spot, but there are not enough playoff spots for all the tied teams, then those teams can neither clinch nor be eliminated. See example 4.
Given a int[] wins (the number of wins each team has), an int gamesLeft (how many games each team has left to play), and an int N (the number of playoff spots available), determine which teams have clinched one of the spots in the playoffs, and which teams have been eliminated. Each team will play gamesLeft games against other teams in the league, but you should assume that each game could be against any other team. Of course, teams cannot play themselves, and each team must play the same number of games. The return value should be a String, where the character at position i represents the status of element i in wins. Each character should be a capital 'C' if the team has clinched, a capital 'E' if it has been eliminated, or a period '.' if the team has neither clinched, nor been eliminated.
|