Re: [閒聊] 每日leetcode

看板Marginalman作者 (通通打死)時間1年前 (2024/11/09 12:02), 1年前編輯推噓4(400)
留言4則, 4人參與, 1年前最新討論串1102/1554 (看更多)
x位數是1的地方 所有elements and完一定要是1 所以這些地方一定要是1 從剩下0的地方開始填 填到n-1 蠻有趣的 不過我好像快被python寵壞 def minEnd(self, n: int, x: int) -> int: ans = '' n-=1 while x>0 or n>0: if (x&1)==1: ans = '1'+ans else: ans = str((n&1)) + ans n = n >> 1 x = x >> 1 return int(ans,2) -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.229.37.69 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1731124975.A.816.html ※ 編輯: DJYOMIYAHINA (125.229.37.69 臺灣), 11/09/2024 12:11:31

11/09 12:17, 1年前 , 1F
大師
11/09 12:17, 1F

11/09 12:24, 1年前 , 2F
大師
11/09 12:24, 2F

11/09 12:31, 1年前 , 3F
我已經被python寵壞了
11/09 12:31, 3F

11/09 19:35, 1年前 , 4F
大師
11/09 19:35, 4F
文章代碼(AID): #1dBjxlWM (Marginalman)
討論串 (同標題文章)
文章代碼(AID): #1dBjxlWM (Marginalman)