vector<int> findErrorNums(vector<int>& nums) {
const int N = ;
int S[N]; int n = nums.size(); for (int i = ; i < N; i++)
{
S[i] = ;
} for (int i = ; i <= n; i++)
{
int m = nums[i - ];
S[m]++;
} int dup = -;
int miss = -; for (int i = ; i <= n; i++)
{
if (S[i] == && dup == -)
{
dup = i;
}
if (S[i] == && miss == -)
{
miss = i;
} }
vector<int> R;
R.push_back(dup);
R.push_back(miss); return R;
}

leetcode645的更多相关文章

  1. [Swift]LeetCode645. 错误的集合 | Set Mismatch

    The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of ...

  2. Leetcode-645 Set Mismatch

    The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of ...

  3. Leetcode645.Set Mismatch错误的集合

    集合 S 包含从1到 n 的整数.不幸的是,因为数据错误,导致集合里面某一个元素复制了成了集合里面的另外一个元素的值,导致集合丢失了一个整数并且有一个元素重复. 给定一个数组 nums 代表了集合 S ...

随机推荐

  1. JVM内存管理中的垃圾回收策略

    JVM垃圾回收策略 1.静态内存分配和回收 编译时已经确定了内存空间大小,程序被加载后则一次性分配好内存空间.程序结束后,则对应栈帧撤销,分配的静态内存空间则被回收. 2.动态内存分配和回收 程序运行 ...

  2. hibernate报错org.hibernate.HibernateException: No CurrentSessionContext configured!

    org.hibernate.HibernateException: No CurrentSessionContext configured! at org.hibernate.internal.Ses ...

  3. python中常见的日期换算

    time模块提供各种操作时间的函数  说明:一般有两种表示时间的方式:       第一种是时间戳的方式(相对于1970.1.1 00:00:00以秒计算的偏移量),时间戳是惟一的       第二种 ...

  4. json与NSString转换

    json to string NSData *jsonData = [NSJSONSerialization dataWithJSONObject:json options:NSJSONWriting ...

  5. Mysql进程管理

    mysql> show processlist;+----+------+-----------+------+---------+------+-------+---------------- ...

  6. java 简单解析wsdl

    static void resolve(String wsdl) throws Exception { DocumentBuilderFactory factory = DocumentBuilder ...

  7. Jfinal整合百度富文本编辑器ueditor

    ueditor配置文件ueditor.config.js修改参数serverUrl:(改为要调用的action) 后台代码 package com.sandu.mega.admin.ueditor; ...

  8. MySQL主从复制的常用拓扑结构

    1.复制的常用拓扑结构 复制的体系结构有以下一些基本原则: (1)    每个slave只能有一个master: (2)    每个slave只能有一个唯一的服务器ID: (3)    每个maste ...

  9. UVA 11637 Garbage Remembering Exam

    #include <iostream> #include <stdio.h> #include <cstring> #include <math.h> ...

  10. Count On A Tree II.

    $n$ 个点的树,数一条链上有多少不同的点 sol: 树上莫队 首先,王室联邦分块 记 $(cu,cv)$ 为当前的链,$(qu,qv)$ 为当前询问的链,维护一个 $vis$ 数组表示“当前点在/不 ...