Back to problems Sign in to unlock
Leetcode
Medium
Math
Strings
Hexadecimal And Hexatrigesimal Conversion
Convert a non-negative integer into two textual representations: hexadecimal and base-36 (hexatrigesimal).
Acceptance 100%
Problem Statement
Problem
Given a non-negative integer, convert it into two different string representations:
- Hexadecimal representation using digits
0-9and lettersA-F - Hexatrigesimal representation, i.e. base 36, using digits
0-9and uppercase lettersA-Z
Return both converted strings. The conversion should follow standard positional numeral system rules, with no leading zeros unless the value itself is 0.
Notes
- For hexadecimal, values
10to15map toAtoF. - For base 36, values
10to35map toAtoZ. - Use uppercase letters in both outputs.
Input Format
- A single non-negative integer
n.
Output Format
- Return or print two strings:
- hexadecimal representation of
n - base-36 representation of
n
- hexadecimal representation of
Constraints
0 <= n- The exact upper bound is not specified in this reconstruction.
- Outputs must not contain leading zeros.
- Use uppercase letters for digits beyond
9.
Examples
Sample cases returned by the problem API.
Example 1
Input
n = 255
Output
"FF", "73"
Explanation
255 in hexadecimal is FF. In base 36, 255 = 7 × 36 + 3, so the representation is 73.
Example 2
Input
n = 0
Output
"0", "0"
Explanation
Zero is represented as 0 in every base.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.
Guided hints
Editorial and discussion links
Concept map and variants
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.