LeetCode题解之 Find the Town Judge
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的更多相关文章
- 【LeetCode】997. Find the Town Judge 解题报告(C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 度 日期 题目地址:https://leetcode ...
- 【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 ...
- #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 ...
- [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 ...
- 【LeetCode题解】二叉树的遍历
我准备开始一个新系列[LeetCode题解],用来记录刷LeetCode题,顺便复习一下数据结构与算法. 1. 二叉树 二叉树(binary tree)是一种极为普遍的数据结构,树的每一个节点最多只有 ...
- leetcode题解-122买卖股票的最佳时期
题目 leetcode题解-122.买卖股票的最佳时机:https://www.yanbinghu.com/2019/03/14/30893.html 题目详情 给定一个数组,它的第 i 个元素是一支 ...
- 【LeetCode题解】3_无重复字符的最长子串(Longest-Substring-Without-Repeating-Characters)
目录 描述 解法一:暴力枚举法(Time Limit Exceeded) 思路 Java 实现 Python 实现 复杂度分析 解法二:滑动窗口(双指针) 思路 Java 实现 Python 实现 复 ...
- 【LeetCode题解】225_用队列实现栈(Implement-Stack-using-Queues)
目录 描述 解法一:双队列,入快出慢 思路 入栈(push) 出栈(pop) 查看栈顶元素(peek) 是否为空(empty) Java 实现 Python 实现 解法二:双队列,入慢出快 思路 入栈 ...
- 【LeetCode题解】232_用栈实现队列(Implement-Queue-using-Stacks)
目录 描述 解法一:在一个栈中维持所有元素的出队顺序 思路 入队(push) 出队(pop) 查看队首(peek) 是否为空(empty) Java 实现 Python 实现 解法二:一个栈入,一个栈 ...
随机推荐
- IdentityServer(13)- 使用 JavaScript 客户端
本文使用的授权码模式,已更新至 .NET Core 2.2 本快速入门将展示如何构建基于浏览器的 JavaScript 客户端应用程序(SPA). 用户将登录 IdentityServer,使用 Id ...
- 部署 YApi 接口管理服务
安装 Node curl -sL https://rpm.nodesource.com/setup_8.x | bash - yum install -y nodejs 安装 MongoDB vi / ...
- mysql 开发进阶篇系列 19 MySQL Server(innodb_flush_log_at_trx_commit与sync_binlog)
一. innodb_flush_log_at_trx_commit 这个参数名称有个log,一看就是与日志有关.是指:用来控制缓冲区(log buffer)中的数据写入到日志文件(log file), ...
- python自动化工具之pywinauto(一个实例)结合pyuserinput
以下是pywinauto使用指南.这个窗口句柄可以在Spy++中查看 (Microsoft Spy++(查看窗口句柄) 10.00.30319 官方最新绿色版) python自动化工具之pywinau ...
- salesforce lightning零基础学习(十二) 自定义Lookup组件的实现
本篇参考:http://sfdcmonkey.com/2017/01/07/custom-lookup-lightning-component/,在参考的demo中进行了简单的改动和优化. 我们在ht ...
- 对小程序框架WePY的精简总结
一.注意点 关闭ES6转ES5关闭上传代码时样式自动补全关闭代码压缩上传本地开发选择dist目录,dist目录也用在开发者工具上实时预览和调试WePY框架对应的开发目录为src二.代码规范 - 变量方 ...
- 项目ITP(二) 二维码 拿起你的手机装一装,扫一扫 【每日一搏】
前言 系列文章:[传送门] 五一,期待的两天假期.我的生日,happy. [吐槽] 学校真恶心,半月前让我给他搞个东西,md,课题不加人.后来又来求,说钱(钱,咱不需要:我猜也不多).到现在,又来了, ...
- centos 7 linux 安装与卸载 jdk 7
一.声明 本文采用操作系统版本: Centos 7 Linux 系统 版本源:CentOS-7-x86_64-DVD-1708.iso 官网下载地址:http://isoredirect.centos ...
- Elasticsearch从入门到精通-Elasticsearch是什么
作者其他ELK快速入门系列文章 logstash快速入门实战指南 Kibana从入门到精通 一.前言 驱动未来商业发展的最重要“能源”不是石油,而是数据.我们还来不及了解它,这个世界已经被它淹没.多年 ...
- [转]分别使用Node.js Express 和 Koa 做简单的登录页
本文转自:https://blog.csdn.net/weixin_38498554/article/details/79204240 刚刚学了Koa2,由于学的不是很深,并没有感受到网上所说的Koa ...