精華區beta Marginalman 關於我們 聯絡資訊
把 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
Pash97143: DJ寶 你別卷了 11/23 00:48
sustainer123: 大佬 養我 11/23 00:51