105.找到冠军

方法一

java 复制代码
class Solution {
    public int findChampion(int[][] grid) {
        int j=0;
        for(int i=1;i<grid.length;i++){
            if(grid[j][i]==0)
                j=i;
        }
        return j;
    }
}
python 复制代码
class Solution(object):
    def findChampion(self, grid):
        j=0
        for i in range(len(grid)):
            if grid[j][i]==0:
                j=i
        return j

方法二

java 复制代码
class Solution {
    public int findChampion(int[][] grid) {
        int count=0;
        for(int i=0;i<grid.length;i++){
            count=0;
            for(int j=0;j<grid[0].length;j++){
                if(grid[i][j]==1){
                    count++;
                }
            }
            if(count==grid.length-1){
                return i;
            }
        }
        return 0;
    }
}
python 复制代码
class Solution(object):
    def findChampion(self, grid):
        count=0
        for i in range(len(grid)):
            count=0
            for j in range(len(grid[0])):
                if grid[i][j]==1:
                    count+=1
            if count==len(grid)-1:
                return i
        return 0
相关推荐
2401_868534787 分钟前
55 个热门网络面试问题及答案
网络·python
aifannihao14 分钟前
ON CONFLICT 冲突后返回空:sqlite3 实测 get-or-create
数据库·python·postgresql·sqlite3·标准库
用户03321266636728 分钟前
使用 Python 合并 Excel 工作簿
python
__underline__33 分钟前
冷门Python知识点008篇:__int__、__index__与__float__,Python数值转换的真实回退顺序?
后端·python
AAA修煤气灶刘哥35 分钟前
我都切到下一张图了,Agent 怎么还在解释上一张?
人工智能·算法·架构
学长毕设36 分钟前
基于SpringBoot景区停车场预约管理系统-附源码
java·spring boot·后端
未秃头的程序猿37 分钟前
800 万条数据批量导出:我用线程池写出了 4 个 bug
java·后端
有个傻瓜37 分钟前
前端订单 ID 查不到详情:Java 雪花 Long 经 JSON 到小程序的精度丢失排查与四种方案实测
java·spring boot·微信小程序·jackson·踩坑复盘
Navigator_Z39 分钟前
LeetCode //C - 1320. Minimum Distance to Type a Word Using Two Fingers
c语言·算法·leetcode
AAA修煤气灶刘哥1 小时前
旧系统要升级,为什么第一步是把旧结果存一份?
java·后端·架构