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
相关推荐
微尘寒风3 小时前
【Git】的安装和使用
java·git
y = xⁿ3 小时前
DeepSeek Harness 学习日记:关于Agent接口,工具调用的底层实现
android·java·学习
侧耳倾听1114 小时前
jwt使用简介
java·jwt
顶点多余4 小时前
那些在算法中适合巩固的知识点---1
java·前端·算法
AI人工智能+电脑小能手4 小时前
大白话说Java设计模式-46-责任链模式(业务实战篇)
java·设计模式·责任链模式·风控校验·servlet filter·spring interceptor·链式处理
jay神5 小时前
【计算机毕业设计】基于SpringBoot的程序教学辅助系统
java·前端·vue.js·spring boot·后端·毕业设计·课程设计
AI情绪识别开源5 小时前
检信 ALLEMOTION OS 加密打包可执行程序 — 全面测试报告版本: v1.3功能测试 / 性能测试 /
开发语言·数据结构·人工智能·功能测试
2601_962066495 小时前
【Sql Server】Update中的From语句,以及常见更新操作方式
android·java·数据库
lupai6 小时前
手机在网状态接口实测效果与质量评估
大数据·python·智能手机·api接口
罗西的思考6 小时前
【Agentic RL / 强化学习框架】Molt 设计解读
人工智能·算法·机器学习