class Solution:
def oddCells(self, n: int, m: int, indices: List[List[int]]) -> int:
rows=[0]*n
cols=[0]*m
for x,y in indices:
rows[x]+=1#使用Python的这种语法可以直接按照题意来模拟
cols[y]+=1
sum=0
for i in range(n):
for j in range(m):
if (rows[i]+cols[j])%2==1:
sum+=1;
return sum
Leetcode:1252. 奇数值单元格的数目
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
LeetCode_圆圈中最后剩下的数字_Math_E
面試題62. 圓圈中最後剩下的數字 class Solution { public int lastRemaining(int n, int m) { // 模擬法 List<Integer> l
放羊的大飞
2020-07-08 10:58:59
LeetCode_单词的压缩编码_Array_M
放羊的大飞
2020-07-08 10:58:58
LeetCode_地图分析_BFS_M
放羊的大飞
2020-07-08 10:58:58
LeetCode_卡牌分组_Array_E
放羊的大飞
2020-07-08 10:58:58
LeetCode_两数之和_Array_E
1. 兩數之和 暴力: class Solution { public int[] twoSum(int[] nums, int target) { int[] res = new int[2];
放羊的大飞
2020-07-08 10:58:58
LeetCode_字符串转换整数 (atoi)_String_M
放羊的大飞
2020-07-08 10:58:58
LeetCode_旋转矩阵_Array_M
01.07. 旋轉矩陣 簡單粗暴: class Solution { public void rotate(int[][] matrix) { int size = matrix.length;
放羊的大飞
2020-07-08 10:58:58
LeetCode_盛最多水的容器_Array_M
11. 盛最多水的容器 暴力... class Solution { public int maxArea(int[] height) { int max = 0; for (int i
放羊的大飞
2020-07-08 10:58:58
LeetCode_除自身以外数组的乘积_Array_M
放羊的大飞
2020-07-08 10:58:58
LeetCode_整数反转_Math_E
7. 整數反轉 class Solution { public int reverse(int x) { long result = 0; while (x != 0) { // 如果是-1
放羊的大飞
2020-07-08 10:58:58
LeetCode_有效的括号_Stack_E
放羊的大飞
2020-07-08 10:58:58
LeetCode_实现 Trie (前缀树)_Trie_M
208. 實現 Trie (前綴樹) class Trie { //定義節點 class TrieNode { boolean isEnd; TrieNode[] next = new
放羊的大飞
2020-07-08 10:58:58
LeetCode_排序数组_Array_M
912. 排序數組 class Solution { public int[] sortArray(int[] nums) { quickSort(nums, 0, nums.length - 1);
放羊的大飞
2020-07-08 10:58:58