The easiest way is to use Integer.toHexString()
I know it is hacky, but it is what it is...
It's not hacky. It's againt the requirement.
According to the instruction, "You must not use any method provided by the library which converts/formats the number to hex directly".
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.