Problem Statement
Peter was recently on a holiday. The holiday lasted for totalDays days. Peter remembers that exactly rainyDays of them were rainy and the others were sunny.
We will use the letters 'R' and 'S' to represent rainy and sunny days. For example, the string "SSSRSS" represents a 6-day holiday during which day 4 was rainy and the other five days were sunny.
We say that the beauty of the holiday is the maximal number of consecutive sunny days during the holiday. For example, the beauty of "SSSRSS" is 3 and the beauty of "RRR" is 0.
Given totalDays and rainyDays, determine the smallest possible beauty of Peter's holiday. Then, construct and return one string that represents such a holiday.
(The returned string should have the correct number of days, it should have the correct number of rainy days, and its beauty must be the smallest among all such strings. If there are multiple optimal solutions, you may return any one of them.)
Definition
- Class:
- Sunshine
- Method:
- weatherReport
- Parameters:
- int, int
- Returns:
- String
- Method signature:
- String weatherReport(int totalDays, int rainyDays)
- (be sure your method is public)
Constraints
- totalDays will be between 1 and 2000, inclusive.
- rainyDays will be between 0 and totalDays, inclusive.
Examples
6
1
Returns: "SSSRSS"
The example from the problem statement. Another correct answer is "SSRSSS".3
3
Returns: "RRR"
Another example from the problem statement. This is the only correct answer.12
8
Returns: "RRSRRSRSRRRS"
8
2
Returns: "SSRSSRSS"
5
0
Returns: "SSSSS"