Problem Statement | | You are given two ints: N and K. Lun the dog is interested in strings that satisfy the following conditions:
- The string has exactly N characters, each of which is either 'A', 'B' or 'C'.
- The string s has exactly K pairs (i, j) (0 <= i < j <= N-1) such that s[i] < s[j].
If there exists a string that satisfies the conditions, find and return any such string. Otherwise, return an empty string. | | Definition | | Class: | ABC | Method: | createString | Parameters: | int, int | Returns: | String | Method signature: | String createString(int N, int K) | (be sure your method is public) |
| | | | Constraints | - | N will be between 3 and 30, inclusive. | - | K will be between 0 and N(N-1)/2, inclusive. | | Examples | 0) | | | | Returns: "ABC" | This string has exactly three pairs (i, j) mentioned in the statement: (0, 1), (0, 2) and (1, 2). |
|
| 1) | | | | Returns: "CBA" | Please note that there are valid test cases with K = 0. |
|
| 2) | | | | Returns: "" | Five characters is too short for this value of K. |
|
| 3) | | | | Returns: "CABBACCBAABCBBB" | Please note that this is an example of a solution; other valid solutions will also be accepted. |
|
|
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
|