网页学习体会

  • 首页
  • 个人博客
您的位置: 首页  >  IT文章  >  【leetcode】找到小镇的法官

【leetcode】找到小镇的法官

分类: IT文章 • 2024-08-09 15:34:49
int findJudge(int N, int** trust, int trustSize, int* trustColSize){
    int total=(N+1)*N/2,i;
    int hash[1001]={0};
    for (i=0; i<trustSize; i++)
    {
        hash[trust[i][0]]=-1;
        if (hash[trust[i][1]]>=0)
            hash[trust[i][1]]+=trust[i][0];        
    }
    for (i=1; i<=N; i++)
        if (hash[i] != -1 && hash[i]+i == total) return i;

    return -1;
}

相关推荐

  • Leetcode 997. 找到小镇的法官
  • LeetCode双周赛#36 1604. 警告一小时内使用相同员工卡大于等于三次的人 1605. 给定行和列的和求可行矩阵 #贪心 #稀疏矩阵 1606. 找到处理最多请求的服务器 #STL #任务分配 #模拟
  • LeetCode 15 3Sum 找到数组里面3个数的和等于指定值
  • Leetcode39->Combination Sum(在数组中找到和为target的组合)
  • 【leetcode】找到小镇的法官
  • LeetCode 41 First Missing Positive(找到数组中第一个丢失的正数)
  • LeetCode997. 找到小镇的法官 Java
  • [LeetCode]485. Max Consecutive Ones 找到最大的连续的1的个数
  • [LeetCode] 448. Find All Numbers Disappeared in an Array 找到数组中消失的数字
  • LeetCode——找到小镇的法官
  • jeecg删除菜单导致角色权限设置点不开的问题解决
  • ASP.NET一个弹出窗口语句,眼见执行到了,但是不弹解决思路
    网站免责声明 网站地图 最新文章 用户隐私 版权申明
本站所有数据收集于网络,如果侵犯到您的权益,请联系网站进行下架处理。   

Copyright © 2018-2021   Powered By 网页学习体会    备案号:   粤ICP备20002247号