1、题目描述

2、问题分析

使用map set数据结构。

3、代码

  int findJudge(int N, vector<vector<int>>& trust) {

         if (trust.size() == )
return ; int n = ;
map<int, int> m;
set<int> s;
for (auto it = trust.begin(); it != trust.end(); it++) {
m[(*it).back()]++;
s.insert((*it).front());
} int peo = INT_MIN;
for (auto it = m.begin(); it != m.end(); it++) {
if (it->second > n){
n = it->second;
peo = it->first;
}
} return ((n == (N - )) && s.find(peo) == s.end()) ? peo : -; }

LeetCode题解之 Find the Town Judge的更多相关文章

  1. 【LeetCode】997. Find the Town Judge 解题报告(C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 度 日期 题目地址:https://leetcode ...

  2. 【leetcode】997. Find the Town Judge

    题目如下: In a town, there are N people labelled from 1 to N.  There is a rumor that one of these people ...

  3. #Leetcode# 997. Find the Town Judge

    https://leetcode.com/problems/find-the-town-judge/ In a town, there are N people labelled from 1 to  ...

  4. [Swift]LeetCode997. 找到小镇的法官 | Find the Town Judge

    In a town, there are N people labelled from 1 to N.  There is a rumor that one of these people is se ...

  5. 【LeetCode题解】二叉树的遍历

    我准备开始一个新系列[LeetCode题解],用来记录刷LeetCode题,顺便复习一下数据结构与算法. 1. 二叉树 二叉树(binary tree)是一种极为普遍的数据结构,树的每一个节点最多只有 ...

  6. leetcode题解-122买卖股票的最佳时期

    题目 leetcode题解-122.买卖股票的最佳时机:https://www.yanbinghu.com/2019/03/14/30893.html 题目详情 给定一个数组,它的第 i 个元素是一支 ...

  7. 【LeetCode题解】3_无重复字符的最长子串(Longest-Substring-Without-Repeating-Characters)

    目录 描述 解法一:暴力枚举法(Time Limit Exceeded) 思路 Java 实现 Python 实现 复杂度分析 解法二:滑动窗口(双指针) 思路 Java 实现 Python 实现 复 ...

  8. 【LeetCode题解】225_用队列实现栈(Implement-Stack-using-Queues)

    目录 描述 解法一:双队列,入快出慢 思路 入栈(push) 出栈(pop) 查看栈顶元素(peek) 是否为空(empty) Java 实现 Python 实现 解法二:双队列,入慢出快 思路 入栈 ...

  9. 【LeetCode题解】232_用栈实现队列(Implement-Queue-using-Stacks)

    目录 描述 解法一:在一个栈中维持所有元素的出队顺序 思路 入队(push) 出队(pop) 查看队首(peek) 是否为空(empty) Java 实现 Python 实现 解法二:一个栈入,一个栈 ...

随机推荐

  1. Ioc及Bean容器(三)

    专题一 IoC 接口及面向接口编程 什么是 IoC Spring 的Bean配置 Bean 的初始化 Spring 的常用注入方式 接口 用于沟通的中介物的抽象化 实体把自己提供给外界的一种抽象化说明 ...

  2. SpringContextHolder 静态持有SpringContext的引用

    import java.util.Map; import org.springframework.context.ApplicationContext; import org.springframew ...

  3. 【bioinfo】生物信息学——代码遇见生物学的地方

    注:从进入生信领域到现在,已经过去快8年了.生物信息学包含了我最喜欢的三门学科:生物学.计算机科学和数学.但是如果突然问起,什么是生物信息学,我还是无法给出一个让自己满意的答案.于是便有了这篇博客. ...

  4. LINUX LVM和快照卷配置和管理

    具体参考这个文章把: http://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_linux_042_lvm.html 1.LVM是什么 逻辑卷管理LVM是一个多 ...

  5. python三大神器之virtualenv

    virtualenv virtualenv用来管理python项目环境,隔离出一个只属于这个项目的虚拟python环境(windows和Linux用法一样). 首先你需要安装virtualenv模块 ...

  6. 痞子衡嵌入式:备受开源社区推崇的分布式版本控制工具(Git)

    大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是分布式版本控制工具Git. 1.为什么需要版本控制系统? 单人软件项目开发过程,往往很多功能都是逐步增加的,在代码开发过程中,有的时候功 ...

  7. Java——this关键字

    前言 this关键字属于Java中比较复杂的关键字之一,若是学习过C++或者其他的一些面向对象语言也会遇到this这个关键字并且都会看到this的含义就是表示当前对象.什么叫做表示当前对象?this在 ...

  8. Nacos系列:欢迎来到Nacos的世界!

    什么是Nacos? Nacos 是构建以"服务"为中心的现代应用架构 (例如微服务范式.云原生范式) 的服务基础设施. Nacos可以做什么? 1.动态配置服务:支持以中心化.外部 ...

  9. OJ:重载 << 运算符

    Description 补足程序,使得下面程序输出的结果是: ****100 #include <iostream> #include <string> using names ...

  10. 【golang-GUI开发】Qt5的安装

    golang一直被认为没有好的GUI库,事实并非如此. 目前有基于gtk+3.0的gotk3:https://github.com/gotk3/gotk3 以及接下来我们要说的qt:https://g ...