Skip to content

Commit ebf7aa8

Browse files
Update 405.py
1 parent 20b2301 commit ebf7aa8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

001-500/405.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,14 @@ def toHex(self, num: int) -> str:
99
ans = c + ans
1010
num = num >> 4
1111
return ans.lstrip('0')
12+
13+
14+
class Solution:
15+
def toHex(self, num: int) -> str:
16+
s, res, num = '0123456789abcdef', '', num & 0xFFFFFFFF
17+
while num:
18+
res += s[num % 16]
19+
num >>= 4
20+
return res[::-1] or '0'
21+
1222

0 commit comments

Comments
 (0)