|
4 | 4 | importjava.util.HashSet;
|
5 | 5 | importjava.util.Set;
|
6 | 6 |
|
7 |
| -/** |
8 |
| - * 1271. Hexspeak |
9 |
| - * |
10 |
| - * A decimal number can be converted to its Hexspeak representation by first converting it to an uppercase hexadecimal string, |
11 |
| - * then replacing all occurrences of the digit 0 with the letter O, and the digit 1 with the letter I. |
12 |
| - * Such a representation is valid if and only if it consists only of the letters in the set {"A", "B", "C", "D", "E", "F", "I", "O"}. |
13 |
| - * Given a string num representing a decimal integer N, return the Hexspeak representation of N if it is valid, otherwise return "ERROR". |
14 |
| - * |
15 |
| - * Example 1: |
16 |
| - * Input: num = "257" |
17 |
| - * Output: "IOI" |
18 |
| - * Explanation: 257 is 101 in hexadecimal. |
19 |
| - * |
20 |
| - * Example 2: |
21 |
| - * Input: num = "3" |
22 |
| - * Output: "ERROR" |
23 |
| - * |
24 |
| - * Constraints: |
25 |
| - * 1 <= N <= 10^12 |
26 |
| - * There are no leading zeros in the given string. |
27 |
| - * All answers must be in uppercase letters. |
28 |
| - * */ |
29 | 7 | publicclass_1271 {
|
30 | 8 | publicstaticclassSolution1 {
|
31 | 9 | publicStringtoHexspeak(Stringnum) {
|
|