Convert a Number to Hexadecimal Problem
Convert a Number to Hexadecimal Problem — ExecCode Easy DSA Practice
Solve the Convert a Number to Hexadecimal problem on ExecCode. Free online easy DSA practice in Math. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given a 32-bit integer num, return a string representing its hexadecimal representation. Your task is to for negative integers, two’s complement method is used. All the letters in the answer string should be lowercase characters, and there should not be any leading zeros in the answer except for the zero itself. Note:You are not allowed to use any built-in library method to directly solve this problem. Return the required answer exactly as shown in the examples.
Examples
Input {"num": 26}; Output 1a. Input {"num": -1}; Output ffffffff
Constraints
-2^31 <= num <= 2^31 - 1
Practice Convert a Number to Hexadecimal free on ExecCode. Browse DSA problems, topic map, and placement guides.