Decimal to Hexadecimal
Given a non-negative decimal integer n, return its hexadecimal representation as an uppercase string. Use digits 0 through 9 and letters A through F. Do not…
Given a non-negative decimal integer `n`, return its hexadecimal representation as an uppercase string. Use digits `0` through `9` and letters `A` through `F`. Do not include a leading zero or `0x` prefix; represent zero as `"0"`.
- `0 <= n <= 10^9` - Letters in the returned representation must be uppercase.
Example 1: input n = 26; output "1A". 26 = 1×16 + 10, and remainder 10 maps to A.
Example 2: input n = 255; output "FF". Both hexadecimal places have value 15, represented by F.
Category: Math & Numbers. Topic: math. Difficulty: Easy. Patterns: math.