[LeetCode&Python] Problem 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 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]
class Solution(object):
def findDisappearedNumbers(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
return list(set([i for i in range(1,len(nums)+1)]).difference(set(nums)))
[LeetCode&Python] Problem 448. Find All Numbers Disappeared in an Array的更多相关文章
- 【leetcode】448. Find All Numbers Disappeared in an Array
problem 448. Find All Numbers Disappeared in an Array solution: class Solution { public: vector<i ...
- 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 ...
- 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 = ...
- 448. Find All Numbers Disappeared in an Array【easy】
448. Find All Numbers Disappeared in an Array[easy] Given an array of integers where 1 ≤ a[i] ≤ n (n ...
- 448. Find All Numbers Disappeared in an Array@python
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and ot ...
- leetcode 448. Find All Numbers Disappeared in an Array -easy (重要)
题目链接: https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/description/ 题目描述: Give ...
- 【LeetCode】448. Find All Numbers Disappeared in an Array 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 方法一:暴力求解 方法二:原地变负做标记 方法三:使用set ...
- [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 ...
- LeetCode 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 ...
随机推荐
- was重要文件位置备忘
软件版本信息--/was/profiles/lsDmgr/properties/version/profile.version(/was/bin/versionInfo.sh) profile模版位置 ...
- win10输入法五笔设置
win10 settings inputApp 1●安装五笔qq ignore / ign ɔ: 2● 操作步骤 3● 五笔设置
- outline: none;
outline: none:用在去掉某个选中后显示的外边框,(追求细节) http://www.w3school.com.cn/cssref/pr_outline.asp
- CSS技巧-文字分散对齐的方法
下面的代码可以在IE中实现文字分散对齐: <table width="300" align="center"> <tr> ...
- nginx+tomcat集群
参考: 简单:http://blog.csdn.net/wang379275614/article/details/47778201 详细:http://www.jb51.net/article/77 ...
- java⑾
1.数组: 01.一组 相同数据类型的集合! 02.数组在内存中会 开辟一串连续的空间来保存数据! ***存储30名学生的姓名! 01.姓名 应该用什么数据类型保存??? String02.难道需要创 ...
- oo作业总结(二)
概述 和前三次作业相比,这几次作业最大的不同是难度的飞跃.遗憾的是在这难度的变化面前,我自己却没有做好充分的准备,错误的低估了作业难度导致给自己带来了很多不必要麻烦和损失.接下来我将对它们进行说明(度 ...
- vue-7-表单
示例: <input v-model="message" placeholder="edit me"> <p>Message is: { ...
- ES6-循环
forEach 方法来遍历数组,不能使用break语句中断循环,也不能使用return语句返回到外层函数 myArray.forEach(function (value) { console.log( ...
- Linux系统命令行中vim编辑器取消高亮显示
由于在使用vim编辑代码的时候不小心忘记首先输入i(insert)模式,导致写的代码出现了棕黄色的阴影显示 摸索了很久终于找到了解决方法: 1.退出vim编译器 2.在在命令行下输入:nohl,回车 ...