标签:== sel 图片 leetcode join turn else style def
题目描述:编码
方法一:
class Solution(object): def encode(self, n): if n == 0: return "" n -= 1 A = [‘0‘ if n % 2 == 0 else ‘1‘] # 01 2345 e = 2 while n >= e: n -= e e *= 2 A.append(‘0‘ if n % e < (e/2) else ‘1‘) return "".join(A[::-1])
标签:== sel 图片 leetcode join turn else style def
原文地址:https://www.cnblogs.com/oldby/p/11905056.html