Re: [闲聊] 每日leetcode

楼主: DJYOMIYAHINA (通通打死)   2024-08-09 00:08:09
剩我写的一坨了==
写得非常坎坷

一二三四五
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
作者: Smallsh (Smallsh)   2023-08-09 00:08:00
大师
作者: sustainer123 (caster)   2024-08-09 00:14:00
我的行数至少你的两倍 渍
作者: rainkaras (rainkaras)   2024-08-09 00:46:00
大师
作者: Rushia (みけねこ的鼻屎)   2024-08-09 00:48:00
py好爽java的白痴原生阵列难用死了

Links booklink

Contact Us: admin [ a t ] ucptt.com