1 Star 0 Fork 0

ZENGWatermelon/LeetCode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
861.翻转矩阵后的得分.py 1.22 KB
一键复制 编辑 原始数据 按行查看 历史
sunzhaoc 提交于 2020-11-24 11:23 . master
'''
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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/watermelonTT/LeetCode.git
git@gitee.com:watermelonTT/LeetCode.git
watermelonTT
LeetCode
LeetCode
master

搜索帮助