1、题目描述

2.问题分析

使的 A[i] = i+1 ,最后检查不满足这个条件的i+1 .即为缺失的值。

3.代码

 vector<int> findDisappearedNumbers(vector<int>& nums) {
for( int i = ; i < nums.size() ; ++i ){
if( nums[i] != nums[ nums[i] - ] ){
swap( nums[i] , nums[nums[i] - ] );
i--;
}
}
vector<int> result ;
for( int i = ; i < nums.size() ; i++){
if( nums[i] != i+ )
result.push_back( i+ );
}
return result ;
}

LeetCode题解之Find All Numbers Disappeared in an Array的更多相关文章

  1. 【leetcode】448. Find All Numbers Disappeared in an Array

    problem 448. Find All Numbers Disappeared in an Array solution: class Solution { public: vector<i ...

  2. LeetCode算法题-Find All Numbers Disappeared in an Array(Java实现)

    这是悦乐书的第232次更新,第245篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第99题(顺位题号是448).给定一个整数数组,其中1≤a[i]≤n(n =数组的大小) ...

  3. 【LeetCode】448. Find All Numbers Disappeared in an Array 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 方法一:暴力求解 方法二:原地变负做标记 方法三:使用set ...

  4. [leetcode]python 448. Find All Numbers Disappeared in an Array

    Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and ot ...

  5. LeetCode——Find All Numbers Disappeared in an Array

    LeetCode--Find All Numbers Disappeared in an Array Question Given an array of integers where 1 ≤ a[i ...

  6. leetcode之Find All Numbers Disappeared in an Array

    问题来源:Find All Numbers Disappeared in an Array 很久没有刷题了,感觉大脑开始迟钝,所以决定重拾刷题的乐趣.一开始不要太难,选一些通过率高的题目做,然后就看到 ...

  7. leetcode 217. Contains Duplicate 287. Find the Duplicate Number 442. Find All Duplicates in an Array 448. Find All Numbers Disappeared in an Array

    后面3个题都是限制在1-n的,所有可以不先排序,可以利用巧方法做.最后两个题几乎一模一样. 217. Contains Duplicate class Solution { public: bool ...

  8. LeetCode_448. Find All Numbers Disappeared in an Array

    448. Find All Numbers Disappeared in an Array Easy Given an array of integers where 1 ≤ a[i] ≤ n (n  ...

  9. 448. Find All Numbers Disappeared in an Array&&645. Set Mismatch

    题目: 448. Find All Numbers Disappeared in an Array Given an array of integers where 1 ≤ a[i] ≤ n (n = ...

随机推荐

  1. android app性能优化大汇总

    这里根据网络上各位大神已经总结的知识内容做一个大汇总,作为记录,方便后续“温故知新”. 性能指标: (1)使用流畅度:  图片处理器每秒刷新的帧数(FPS),可用来指示页面是否平滑的渲染.高的帧率可以 ...

  2. mpvue图片轮播遇到的问题

    小程序官方写法: <swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" i ...

  3. python采用pika库使用rabbitmq总结,多篇笔记和示例

    这一段时间学习了下rabbitmq,在学习的过程中,发现国内关于python采用pika库使用rabbitmq的资料很少,官网有这方面的资料,不过是都英文的.于是笔者结合自己的理解,就这方面内容写了一 ...

  4. Elasticsearch java客户端调用cat服务

    开发环境,测试环境,预发环境和生产环境一般相互隔离的,使用开发环境或者测试环境可以使用cat来查看索引的情况 例如: 但预防环境和测试环境是不允许访问的,那怎么办呢? 可以使用后台来查看上述信息,提供 ...

  5. es6学习笔记7--Set

    Set 基本用法 ES6提供了新的数据结构Set.它类似于数组,但是成员的值都是唯一的,没有重复的值. Set本身是一个构造函数,用来生成Set数据结构. var s = new Set(); [2, ...

  6. VS2012 生成项目报 "Lc.exe已退出,代码为-1" 错误

    解决方法:删除项目下Properties文件下的license.licx文件即可.

  7. .1-浅析webpack源码之webpack.cmd

    此系列随时可能断更,毕竟我是解释型源码分析…… tips:本系列源码版本为3.10.0 尝试看过Spring的源码,有点烧脑,所以还是重回JS吧! 在配置完环境变量后,可以通过webpack指令进行打 ...

  8. 浅析Java源码之Math.random()

    从零自学java消遣一下,看书有点脑阔疼,不如看看源码!(๑╹◡╹)ノ""" ​ JS中Math调用的都是本地方法,底层全是用C++写的,所以完全无法观察实现过程,Jav ...

  9. VS2017 IIS 部署.net core web项目

    1.点击IIS,查看模块 查看是否安装了 AspNetCoreModule 模块,如果没有安装可下载:https://dotnet.microsoft.com/download 下载安装后,即可部署项 ...

  10. 【题解】LFYZNoip前水题赛 T6

    垃圾出题人们在30分钟内完成了讨论,出题,命题,造数据,跑std的所有环节 luv的化学竞赛题 题目背景 luv_letters 在肝化学竞赛题,他的梦想是混个省一,但是遗憾的是他今年的省二莫名消失了 ...