Tap here to switch tabs
Problem
Submissions

Problem: Convert a Number to Hexadecimal

Convert a Number to Hexadecimal turns an integer into a lowercase hexadecimal string, using two’s complement for negatives and no leading zeros except for zero.

Statement

Given an integer num, return a string representing its hexadecimal representation. For negative integers, two’s complement formatting is used.

All letters in the returned hexadecimal string must be lowercase, and the string must not contain any leading zeros unless the number itself is 00.

Constraints:

  • −231≤-2^{31} \leq num ≤231−1\leq 2^{31} - 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Convert a Number to Hexadecimal

Convert a Number to Hexadecimal turns an integer into a lowercase hexadecimal string, using two’s complement for negatives and no leading zeros except for zero.

Statement

Given an integer num, return a string representing its hexadecimal representation. For negative integers, two’s complement formatting is used.

All letters in the returned hexadecimal string must be lowercase, and the string must not contain any leading zeros unless the number itself is 00.

Constraints:

  • −231≤-2^{31} \leq num ≤231−1\leq 2^{31} - 1