代码拉取完成,页面将自动刷新
'''
Description:
Version: 1.0
Author: Vicro
Date: 2020-11-19 15:11:19
LastEditTime: 2020-11-19 16:02:41
FilePath: \Leetcode\Chinese\861.翻转矩阵后的得分.py
'''
#
# @lc app=leetcode.cn id=861 lang=python3
#
# [861] 翻转矩阵后的得分
#
# @lc code=start
class Solution:
def matrixScore(self, A):
# Caculate Row
for row in range(len(A)):
if A[row][0] == 0:
A[row] = [1 - tmp for tmp in A[row]]
# Caculate Col
for col in range(1, len(A[0])): # you have already make the 1-st element of each row to 1, so you do not need to judge it
one_num = sum(A[row][col] for row in range(len(A)))
if one_num < len(A) - one_num: # Zero Num
for row in range(len(A)):
A[row][col] = 1 - A[row][col]
ans = 0
# for row in range(len(A)):
# for col in range(len(A[0])):
# if A[row][col] == 1:
# ans += 2**(len(A[0])-1-col)
for row in range(len(A)):
tempA = A[i][::-1]
item = for index, val in range(zip())
return ans
sol = Solution()
B = sol.matrixScore([[0,1],[0,1],[0,1],[0,0]])
print(B)
# @lc code=end
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。