Re: [閒聊] 每日leetcode

看板Marginalman作者 (通通打死)時間2月前 (2025/09/20 00:06), 編輯推噓1(100)
留言1則, 1人參與, 2月前最新討論串1523/1548 (看更多)
不知道在幹嘛 蝦雞巴寫一通 對不起 class Spreadsheet: def __init__(self, rows: int): self.data = [[0]*26 for _ in range(rows+1)] def setCell(self, cell: str, value: int) -> None: col = ord(cell[0])-ord('A') row = int(cell[1:]) self.data[row][col] = value def resetCell(self, cell: str) -> None: col = ord(cell[0])-ord('A') row = int(cell[1:]) self.data[row][col] = 0 def getValue(self, formula: str) -> int: first = formula[1:].split('+')[0] first_val = None if ord('A') <= ord(first[0]) <= ord('Z'): col = ord(first[0])-ord('A') row = int(first[1:]) first_val = self.data[row][col] else: first_val = int(first) second = formula[1:].split('+')[1] second_val = None if ord('A') <= ord(second[0]) <= ord('Z'): col = ord(second[0])-ord('A') row = int(second[1:]) second_val = self.data[row][col] else: second_val = int(second) return first_val + second_val -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.132.58.28 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1758298018.A.006.html

09/20 00:15, 2月前 , 1F
大師
09/20 00:15, 1F
文章代碼(AID): #1epN-Y06 (Marginalman)
討論串 (同標題文章)
文章代碼(AID): #1epN-Y06 (Marginalman)