作者DJYOMIYAHINA (通通打死)
看板Marginalman
標題Re: [閒聊] 每日leetcode
時間Fri Aug 9 00:08:09 2024
剩我寫的一坨了==
寫得非常坎坷
唉
一二三四五
def spiralMatrixIII(self, rows: int, cols: int, rStart: int, cStart: int) ->
List[List[int]]:
diff = [0,1,0,-1,0]
ans = [[rStart,cStart]]
idx = 0
while len(ans) < (rows*cols):
cur_i = idx
for i in range((cur_i//2+1)):
rStart += diff[cur_i%4]
cStart += diff[cur_i%4+1]
if 0<=rStart<rows and 0<=cStart<cols:
ans.append([rStart,cStart])
idx += 1
return ans
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.229.37.69 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1723133291.A.18D.html
→ Smallsh: 大師 08/09 00:08
推 sustainer123: 我的行數至少你的兩倍 漬 08/09 00:14
→ rainkaras: 大師 08/09 00:46
→ Rushia: py好爽java的白癡原生陣列難用死了 08/09 00:48