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的更多相关文章

  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 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 ...

  3. 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 = ...

  4. 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 ...

  5. 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 ...

  6. leetcode 448. Find All Numbers Disappeared in an Array -easy (重要)

    题目链接: https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/description/ 题目描述: Give ...

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

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

  8. [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 ...

  9. 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 ...

随机推荐

  1. PE文件结构解析

    说明:本文件中各种文件头格式截图基本都来自看雪的<加密与解密>:本文相当<加密与解密>的阅读笔记. 1.PE文件总体结构 PE文件框架结构,就是exe文件的排版结构.也就是说我 ...

  2. jeasyUI DataGrid 根据屏幕宽度自适应, 改变右侧滚动条Size

    PC浏览器的Datagrid可以显示多几列,但是在手机浏览器时,只能有选择性的显示前几列. $(window).resize(function () { if (document.body.clien ...

  3. liunx文件操作 文件查看

    文件的阅读命令 head 命令 head命令可以用来查看文件的开头部分,命令的格式是: head 文件名 默认设置,它只查看文件的前10行.但可以通过指定一个数字选项来改变要显示的行数,命令如下 he ...

  4. mybatis输出sql语句

    方法一: 这种方法是mybatis官网上介绍的,比较好用: log4j.properties: log4j.rootLogger=ERROR,consolelog4j.appender.console ...

  5. Sql Server 中 根据列名查询表名

    已知列名 ELEMENT_ID ,查询所属表名称 Select O.name objectName, C.name ColumnName from sys.columns C inner join s ...

  6. angular 离开页面相关操作

    $scope.$on("$destroy", function() { $interval.cancel(autoRefresh);})

  7. log4j的参数配置(转)

    转载:log4j.properties文件各参数含义与配置   以下是配置文件log4j.properties的一些属性: log4j.rootLogger=WARN, stdout, Rlog4j. ...

  8. ClickOnce 和管理员权限

    有些程序需要管理员权限需要运行,同时又想用ClickOnce进行发布,这时候就麻烦了,两者是互斥的. 解决方案是,去掉管理员权限的要求,可以进行发布. 程序启动的时候,加载程序员权限的请求. 代码如下 ...

  9. Oracle备份归档日志文件的两种方法比较

    备份归档日志方式有两种:  1 单独备份归档日志:backup archivelog all  2 在执行备库时一起备份归档日志:backup database plus archivelog;  这 ...

  10. day 57 data 插件 表的增删改查

    一 data的含义 在匹配的元素集合中的所有元素上存储任意相关数据或返回匹配的元素集合中的第一个元素的给定名称的数据存储的值.      1 .data(key, value):     描述:在匹配 ...