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. centos 安装 TortoiseSVN svn 客户端

    1 安装 svn客户端 yum install -y subversion 2 常用命令操作   检出命令 svn checkout http://svn.com/path

  2. unity3D打包发布Apk详细步骤

    1.复制android-sdk-windows文件夹到C盘或者D盘或者你可以找到的任意盘任意目录,注意:不能在中文目录下!! 复制完成之后,打开unity,新建一个项目,打开Edit-Preferen ...

  3. Python Django 之 Template 模板的使用

    一.模板样式 注意: 1.url urlpatterns = { path('admin/', admin.site.urls), path('order/', views.order), path( ...

  4. Saiku部分函数解析(八)

    Saiku函数解析 1.   now()  :  获取当前日期 直接使用即可 2. IIF(logic_exp, string, string): IIF判断,logic_exp是逻辑表达式,结果为t ...

  5. Linux搭建Hadoop集群---Jdk配置

    三台虚拟机:master slave1 slave2 192.168.77.99 master 192.168.77.88 slave1 192.168.77.77 slave2   1.修改主机名: ...

  6. 深入理解java虚拟机---垃圾回收(十一)

    1.垃圾回收要解决的问题 可以通过配置虚拟机参数来打印出内存日志: -verbose:gc -XX:+PrintGCDetails 垃圾收集(Garbage Collection,GC),要设计一个G ...

  7. tomcat 启动Spring boot 项目

    SpringBoot 项目如何在tomcat容器中运行 1.相关连接: https://blog.csdn.net/u010598360/article/details/78789197/ 2.修改打 ...

  8. android 应用程序中执行Linux 命令

    ADB 无线调试命令son = "setprop service.adb.tcp.port 5555\n" + "stop adbd\n" + "st ...

  9. LeetCode子集问题

    给定一组不含重复元素的整数数组 nums,返回该数组所有可能的子集(子集当中不包括重复的元素) 代码如下: def subsets(nums): target=[[]] for num in nums ...

  10. synchronized(八)

    package com.bjsxt.base.sync006;/** * 同一对象属性的修改不会影响锁的情况 * @author alienware * */public class ModifyLo ...