Convert a Number to Hexadecimal – LeetCode 405
Problem
Description
Given an integer, write an algorithm to convert it to hexadecimal. For negative integer, two’s complement method is used.
Answer
Original
Code
1 | class Solution { |
思路
简单的转换负数然后进行进制转换。时间复杂度$O(log{n})$,空间复杂度$O(log{n})$。
耗时$4$ ms,排名$95.87\%$
Better
思路
还没看到更好的思路。