博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LeetCode 448 Find All Numbers Disappeared in an Array
阅读量:7093 次
发布时间:2019-06-28

本文共 735 字,大约阅读时间需要 2 分钟。

题目

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

Find all the elements of [1, n] inclusive that do not appear in this array.

Could you do it without extra space and in O(n) runtime? You may assume the returned list does not count as extra space.

Example:

Input:[4,3,2,7,8,2,3,1]Output:[5,6]复制代码

to see which companies asked this question.

代码

func findDisappearedNumbers(_ nums: [Int]) -> [Int] {    var tmp = nums;    var arr: [Int] = []    for i in 0..
0 { tmp[index] *= -1 } } for i in 0..
0 { arr.append(i+1) } } return arr;}复制代码

转载于:https://juejin.im/post/5a3779226fb9a045186ad580

你可能感兴趣的文章
字典树(Trie tree)
查看>>
证书管理机构——CA
查看>>
js metro仿win8卡片效果
查看>>
我的友情链接
查看>>
Samba服务器的配置 , nfs配置解析
查看>>
Android Selector 与 Shape 基本用法
查看>>
通信工程师互联网技术数据库系统概述
查看>>
使用脚本实现自动化建立小Linux与命令移植
查看>>
rman差异增量及累积增量的区别
查看>>
glide
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
document.body属性
查看>>
诚聘Java高级开发工程师
查看>>
linux 下查看登陆用户
查看>>
趁热来一发——关于避免死锁时测试结果颠覆三观不得不思考虫生这件小事
查看>>
我的友情链接
查看>>
人脉通分享工能,点击分享到微信或者qq的分享链接打开H5,提示用户用浏览器打开,点击下载,有有app...
查看>>
Java:String和Date、Timestamp之间的转换
查看>>
Mongodb概述
查看>>