116th LeetCode Weekly Contest N-Repeated Element in Size 2N Array
In a array A
of size 2N
, there are N+1
unique elements, and exactly one of these elements is repeated N times.
Return the element repeated N
times.
Example 1:
Input: [1,2,3,3]
Output: 3
Example 2:
Input: [2,1,2,5,3,2]
Output: 2
Example 3:
Input: [5,1,5,2,5,3,5,4]
Output: 5
Note:
4 <= A.length <= 10000
0 <= A[i] < 10000
A.length
is even
这种,没啥好说的吧
class Solution {
public:
int repeatedNTimes(vector<int>& A) {
int len = A.size();
int num = len/;
map<int,int>Mp;
for(int i=;i<len;i++){
Mp[A[i]]++;
}
for(auto it : Mp){
int x = it.second;
//cout<<x<<endl;
if(x == num){
return it.first;
}
}
}
};
116th LeetCode Weekly Contest N-Repeated Element in Size 2N Array的更多相关文章
- LeetCode--Sort Array By Parity && N-Repeated Element in Size 2N Array (Easy)
905. Sort Array By Parity (Easy)# Given an array A of non-negative integers, return an array consist ...
- 【Leetcode_easy】961. N-Repeated Element in Size 2N Array
problem 961. N-Repeated Element in Size 2N Array solution: class Solution { public: int repeatedNTim ...
- 【LeetCode】961. N-Repeated Element in Size 2N Array 解题报告(Python & C+++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字典 日期 题目地址:https://leetcod ...
- LeetCode 961. N-Repeated Element in Size 2N Array
In a array A of size 2N, there are N+1 unique elements, and exactly one of these elements is repeate ...
- LeetCode 961 N-Repeated Element in Size 2N Array 解题报告
题目要求 In a array A of size 2N, there are N+1 unique elements, and exactly one of these elements is re ...
- 【leetcode】961. N-Repeated Element in Size 2N Array
题目如下: In a array A of size 2N, there are N+1 unique elements, and exactly one of these elements is r ...
- [Swift]LeetCode961. 重复 N 次的元素 | N-Repeated Element in Size 2N Array
In a array A of size 2N, there are N+1 unique elements, and exactly one of these elements is repeate ...
- LC 961. N-Repeated Element in Size 2N Array【签到题】
In a array A of size 2N, there are N+1 unique elements, and exactly one of these elements is repeate ...
- 116th LeetCode Weekly Contest Maximum Width Ramp
Given an array A of integers, a ramp is a tuple (i, j) for which i < j and A[i] <= A[j]. The ...
随机推荐
- 2014年Linux 和开源技术回顾盘点
ZDNet科技观察家StevenJ.Vaughan-Nichols在年终发表了对Linux和开源技术这一年跌宕起伏的总结,细数这一年中的惊喜和不堪. 2014Linux之殇 “心脏出血(Heartbl ...
- SQLAlchemy(ORM框架)
SQLAlchemy SQLAlchemy概述 2 3 4 5 6 7 8 9 10 11 12 13 MySQL-Python mysql+mysqldb://<user>:&l ...
- jq获取table总行数
var rows = $('table').find("tr").length;
- oracle数据库数据类型和约束
今天为大家分享一下关键数据库里面的数据类型和约束.我们都知道国家要讲法律,干什么事情都要遵守法律,比如小的时候你上学的时候要遵守课堂纪律.不能迟到和早退,同样的我们在数据库中创建一些表.或者查询一些表 ...
- 软件工程:Java实现WC.exe基本功能
项目相关要求 GitHub地址:https://github.com/3216004716/WC 实现一个统计程序,它能正确统计程序文件中的字符数.单词数.行数,以及还具备其他扩展功能,并能够快速地处 ...
- ORACLE_EBS_R12_采购到入库所经历的表
--采购到入库所经历的表 --0.请购单 --创建请购单方式有 --a.从外挂系统导入请购的接口表PO_REQUISITIONS_INTERFACE_ALL,并允许请求(名称:导入申请) SELECT ...
- 《PRC:更新项目汇总额》报错
请求报红,日志如下: +---------------------------------------------------------------------------+ 项目: Version ...
- 尝鲜.net core2.1 ——编写一个global tool
本文内容参考微软工程师Nate McMaster的博文.NET Core 2.1 Global Tools 用过npm开发都知道,npm包都可以以全局的方式安装,例如安装一个http-server服务 ...
- webapi put 请求405问题
put 请求的时候 浏览器会像服务器发送两个请求 如何没做任何配置第一个options请求是会报错的 这是需要配置路由给options作响应 这时options请求就通过了,然后你们会看到你的put ...
- 制作百度地图离线JavaScript API加载本地瓦片地图
全面介绍,请看下列介绍地址,改写目前最新版本的百度V2.0地图,已全面实现离线操作,能到达在线功能的95%以上 http://api.jjszd.com:8081/apituiguang/gistg. ...