class Solution(object): def toHex(self, num): return ''.join( '0123456789abcdef'[(num >> 4 * i) & 15] for i in range(8) )[::-1].lstrip('0') or '0'
res *cough* :-P
I'll think about more, but for now I'll mention that
'0123456789abcdef' is shorter than
(string.digits + string.ascii_letters) and
15 is shorter than
@StefanPochmann Thanks Stefan.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.