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. 执行CUnit测试出错

    est/test_fifo.test: error while loading shared libraries: libcunit.so.1: cannot open shared object f ...

  2. Django框架 之 form组件

    Django框架 之 form组件 浏览目录 Form介绍 普通的登录 使用form组件 Form详情 常用字段 校验 进阶 使用Django Form流程 一.Form介绍 我们之前在HTML页面中 ...

  3. DataTable对象的操作问题

    DataTable,DataRow,DataClomun三种对象都是引用类型. C#中值的传递方式分为值传递与引用传递. 1.复制DataTable对象   //以下做法是错误的,dt1和dt2引用的 ...

  4. oracle数据库单表查询

    今天给大家分享的是关于数据库的单表查询,像单表查询/多表查询/分组查询/子查询,这些方法的使用在实际项目过程中会经常用到,作为一名合格的测试人员如果不会数据库那肯定是不行的,行走江湖可能随时会面临被侮 ...

  5. Python基础入门-For循环

    For循环的功能比较强大,他可以帮助我们实现很多重复性的工作.而且for循环能迭代不同的数据结构.他的应用也十分的广泛,作为初学者,我们需要对循环的概念多加理解和练习.接下来我们就来学习for循环的一 ...

  6. python3安装 feedparser

    在看<集体智慧编程>时碰到python3环境下安装feedparser的问题,搜索发现很多人碰到此问题,最终找以下方法解决. how to install feedparser on py ...

  7. Oracle的列操作(增加列,修改列,删除列),包括操作多列

    增加一列: alter table emp4 add test varchar2(10); 修改一列: alter table emp4 modify test varchar2(20); 删除一列: ...

  8. ORACLE_ERP帐务分录

      ORACLE MRPII各模块会计分录   第一章 采购模块 一.资产采购(科目来源:库存组织) 1.物料接收 借  材料采购     接收数量*采购单价 贷 应计暂估     接收数量*采购单价 ...

  9. 微信运动数据抓取(Python)

    "微信运动"能够向朋友分享一个包含有运动数据的网页,网页中就有我们需要的数据.url类似于:http://hw.weixin.qq.com/steprank/step/person ...

  10. Android ViewPager + Fragment的布局

    ViewPager And Fragment 1.之前有篇博客是讲ViewPager的用法的:http://www.cnblogs.com/liangstudyhome/p/3773156.html ...