Re: [閒聊] 每日leetcode

看板Marginalman作者 (通通打死)時間1年前 (2024/11/23 00:48), 1年前編輯推噓1(101)
留言2則, 2人參與, 1年前最新討論串1143/1554 (看更多)
把 row 跟 inverse(row) 視為一樣 然後去找max count 說是這樣說 我也很不會用 就全部硬做string來稿== 看答案好像有其他特別的方法 明天再來研究 先睡 def maxEqualRowsAfterFlips(self, matrix: List[List[int]]) -> int: def flip(s): tmp = [] for c in s: if c == '0': tmp.append('1') else: tmp.append('0') return "".join(tmp) mp = {} for row in matrix: mp["".join([str(i) for i in row])] += 1 ans = 0 for key, val in mp.items(): cur_cnt = val if flip(key) in mp: cur_cnt += mp[flip(key)] ans = max(ans, cur_cnt) return ans -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 125.229.37.69 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1732294102.A.E85.html ※ 編輯: DJYOMIYAHINA (125.229.37.69 臺灣), 11/23/2024 00:48:40

11/23 00:48, 1年前 , 1F
DJ寶 你別卷了
11/23 00:48, 1F

11/23 00:51, 1年前 , 2F
大佬 養我
11/23 00:51, 2F
文章代碼(AID): #1dGBNMw5 (Marginalman)
討論串 (同標題文章)
文章代碼(AID): #1dGBNMw5 (Marginalman)