Given a 32-bit integer `num`, return its hexadecimal representation as a string of lowercase digits with no leading zeros (except for the number 0 itself, which is `"0"`). Negative numbers use two's complement, so -1 becomes `"ffffffff"`. Do not use a built-in conversion function.
Given a 32-bit integer num, return its hexadecimal representation as a string of lowercase digits with no leading zeros (except for the number 0 itself, which is "0"). Negative numbers use two's complement, so -1 becomes "ffffffff". Do not use a built-in conversion function.
Example 1:
Input: {"num":26}
Output: 1a
Constraints:
−231≤num≤231−1
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"num":26}
num = 26. One hex digit holds exactly 4 bits, so we can read the answer off the 32-bit pattern one nibble at a time.