This is a premium problem. We're working on making it available for free soon.
Use these hints if you're stuck. Try solving on your own first.
Convert the given number to hexadecimal.
Replace all 0 and 1 with 'O' and 'I'.
Check if the final string has any numerical digits.
Solutions for this premium problem will be available for free soon.
Browse Free ProblemsWatch expert explanations and walkthroughs
Practice problems asked by these companies to ace your technical interviews.
Explore More ProblemsJot down your thoughts, approach, and key learnings
Hexspeak is generally considered an easy string and number conversion problem. While it may not appear exactly in FAANG interviews, similar problems involving base conversion and string manipulation are common.
The optimal approach is to convert the given decimal string into its hexadecimal representation and then validate each character. Replace '0' with 'O' and '1' with 'I', while keeping 'A'–'F'. If any other digits appear, return "ERROR".
No complex data structures are required. A simple string or character array is sufficient to store and iterate through the hexadecimal representation while applying the required transformations.
Hexspeak is defined using hexadecimal characters, so the decimal input must first be converted to base 16. Once converted, the digits can be validated and mapped to the allowed Hexspeak characters.