Problem Statement | |||||||||||||
Recently, you went to a fair where one of the attractions was an oracle who would give you your horoscope for the next several days. She wasn't very precise though; all she would say is whether you would have a Good ('G') or Bad ('B') day on a particular day. Besides not being very precise, she was very inconsistent: she could be right AT MOST R times in a row, and she could be wrong AT MOST W times in a row.
Create a class Horoscope, which contains a method maxGoodDays. The method takes a String[] predictions, an int R and an int W as input. The elements of predictions are strings containing only the characters 'G' or 'B', indicating whether your horoscope for that day was predicted to be good or bad. (Note that you should concatenate the elements of predictions and consider the entire string the predictions). The method should return the maximum number of Good days that you can experience given the predictions, and values for R and W. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | predictions will contain between 1 and 50 elements inclusive. | ||||||||||||
- | Each element of predictions will contain between 1 and 50 characters inclusive. | ||||||||||||
- | Each element of predictions will contain only the characters 'G' or 'B'. | ||||||||||||
- | R will be between 1 and 50 inclusive. | ||||||||||||
- | W will be between 1 and 50 inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|