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:

  1. 4 <= A.length <= 10000
  2. 0 <= A[i] < 10000
  3. 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的更多相关文章

  1. 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 ...

  2. 【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 ...

  3. 【LeetCode】961. N-Repeated Element in Size 2N Array 解题报告(Python & C+++)

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

  4. 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 ...

  5. 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 ...

  6. 【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 ...

  7. [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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. Docker学习笔记_安装和使用nginx

    一.软件环境 1.宿主机OS:Win10 64位 2.虚拟机OS:Ubuntu 18.04,虚拟机IP:192.168.8.25 3.Docker安装在虚拟机Ubuntu 18.04上 二.安装过程 ...

  2. 11.BETWEEN 操作符

    BETWEEN 操作符在 WHERE 子句中使用,作用是选取介于两个值之间的数据范围. BETWEEN 操作符 操作符 BETWEEN ... AND 会选取介于两个值之间的数据范围.这些值可以是数值 ...

  3. Mybatis——Spring整合

    一.引入依赖 Spring的相关jar包 mybatis-3.4.1.jar mybatis-spring-1.3.0.jar mysql-connector-java-5.1.37-bin.jar ...

  4. Eclipse中新建applet 错误

    出现的问题:  “错误,请单击以获取详细信息” Java Plug-in 1.6.0_45 使用 JRE 版本 1.6.0_45-b06 Java HotSpot(TM) Client VM 用户主目 ...

  5. 利用 Aspose.Words 组件,在不依赖与 Office 组件的情况下把 Word 文件转换成 HTML 代码。

    首先利用 Nuget 获取 Aspose.Words.dll public ActionResult AsposeWordsDemo() { string srcFileName = Server.M ...

  6. The user specified as a definer (”@sa’%') does not exist 解决方法

    mysql数据库报错The user specified as a definer (”@sa’%') does not exist.尝试过两种方式,第一种重启之后好用,但是一会就又不好用了.第二种算 ...

  7. Java 集合框架必记框架图

  8. fork()的写时复制技术(转载)

    本文转载自http://www.cnblogs.com/wuchanming/p/4495479.html,为了方便以后查看... 写时复制技术最初产生于Unix系统,用于实现一种傻瓜式的进程创建:当 ...

  9. Java变量的修饰符

    1.public public的类.类属变量及方法,包内及包外的任何类均可以访问: 2.protect protected的类.类属变量及方法,包内的任何类,及包外的那些继承了此类的子类才能访问: 3 ...

  10. delphi取括号内或括号外的内容

    function TSetParkForm.RemoveSgin(str: string): string; // 去掉括号内的内容(包括括号) var i1, i2, i: integer; beg ...