Leetcode Problem 1271. Hexspeak

1271. Hexspeak

Leetcode Solutions

Convert Decimal to Hexspeak

  1. Convert the input string num to a long integer.
  2. Convert the long integer to its hexadecimal representation as a string.
  3. Convert the hexadecimal string to uppercase.
  4. Replace all occurrences of '0' with 'O' and '1' with 'I' in the hexadecimal string.
  5. Iterate over the modified hexadecimal string.
  6. If any character is a digit, return 'ERROR'.
  7. If all characters are valid Hexspeak characters, return the modified hexadecimal string.
UML Thumbnail

Mapping Hexadecimal to Hexspeak

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...