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:

  1. Input: [1,2,3,3]
  2. Output: 3

Example 2:

  1. Input: [2,1,2,5,3,2]
  2. Output: 2

Example 3:

  1. Input: [5,1,5,2,5,3,5,4]
  2. Output: 5

Note:

  1. 4 <= A.length <= 10000
  2. 0 <= A[i] < 10000
  3. A.length is even
  1. class Solution {
  2. public:
  3. int repeatedNTimes(vector<int>& A) {
  4. map<int,int> m;
  5. for(int i=; i<A.size(); i++){
  6. if(m.count(A[i])) return A[i];
  7. m[A[i]] = i;
  8. }
  9. }
  10. };

LC 961. N-Repeated Element in Size 2N Array【签到题】的更多相关文章

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

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

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

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

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

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

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

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

  9. LeetCode.961-2N数组中N次重复的元素(N-Repeated Element in Size 2N Array)

    这是悦乐书的第365次更新,第393篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第227题(顺位题号是961).在大小为2N的数组A中,存在N+1个唯一元素,并且这些元 ...

随机推荐

  1. TCP超时与重传

    TCP提供可靠的传输层.它使用的方法之一就是确认从另一端收到的数据.但数据和确认都有可能丢失.TCP通过在发送时设置一个定时器来解决这种问题.如果当定时器溢出时还没收到确认,他就重传数该数据.对任何实 ...

  2. 【3】Zookeeper中的角色

    一.Zookeeper角色的分类 领导者(leader) Leader服务器为客户端提供读服务和写服务. 学习者(learner) 跟随者(follower) Follower服务器为客户端提供读服务 ...

  3. current status of the installation and the internationalization of Samba 3.0

    Only about 8 months from release of Samba 3.0.0, there is beginning to be the transition from 2.2.x. ...

  4. SQL语句复习【专题四】

    SQL语句复习[专题四] 多表查询 sql 92多表查询 sql92.sql99 标准--查询所有员工的姓名,部门编号,部门名称select * from empselect * from dept- ...

  5. libusb_transfer

    http://libusb.sourceforge.net/api-1.0/structlibusb__transfer.html int libusb_control_transfer(libusb ...

  6. Java常用类(一)Math类和Random类

    一.Math类 Math类中有一些常用的数学函数,比较简单,不进行详细解释,仅举例说明: 1.绝对值和取整 import java.lang.Math; public class Mat { publ ...

  7. BZOJ2238 Mst[最小生成树+树剖+线段树]

    跑一遍mst.对于非mst上的边,显然删掉不影响. 如果删边在树上,相当于这时剩下两个连通块.可以证明要重新构成mst只需要再加一条连接两个连通块的最小边,不会证,yy一下,因为原来连通块连的边权和已 ...

  8. 喜大普奔!.NET界面控件DevExpress v19.2发布,快来下载体验

    DevExpress Universal Subscription(又名DevExpress宇宙版或DXperience Universal Suite)是全球使用广泛的.NET用户界面控件套包,De ...

  9. jquery button选择器 语法

    jquery button选择器 语法 作用::button 选择器选取类型为 button 的 <button> 元素和 <input> 元素.大理石平台价格表 语法:$(& ...

  10. angular打包(三):pkg

    希望打包成1个web服务,运行exe,启动 angular,供浏览器显示. 问题分析: 其实angular编译后,都是静态文件了.只需要打包express,让express可以以exe的形式运行就可以 ...