public class Solution
{
public int MissingNumber(int[] nums)
{
var list = nums.OrderBy(x => x).ToList(); var preNum = ; foreach (var l in list)
{
if (l != preNum)
{
return preNum;
}
preNum++;
}
return preNum;
}
}

https://leetcode.com/problems/missing-number/#/description

补充一个python的实现:

 class Solution:
def missingNumber(self, nums):
missing = len(nums)
for i, num in enumerate(nums):
missing ^= i ^ num
return missing

leetcode268的更多相关文章

  1. Leetcode-268 Missing Number

    #268.  Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find ...

  2. [Swift]LeetCode268. 缺失数字 | Missing Number

    Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missin ...

  3. leetcode268缺失数字

    int missingNumber(int* nums, int numsSize) { ) /; ;i<numsSize;i++){ sum = sum - nums[i]; } return ...

  4. [leetcode268]Missing Number

    Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missin ...

  5. LeetCode268.缺失数字

    268.缺失数字 描述 给定一个包含 0, 1, 2, ..., n 中 n 个数的序列,找出 0 .. n 中没有出现在序列中的那个数. 示例 示例 1: 输入: [3,0,1] 输出: 2 示例 ...

  6. leetcode268:Missing Number

    描写叙述 Given an array containing n distinct numbers taken from 0, 1, 2, -, n, find the one that is mis ...

  7. LeetCode172 Factorial Trailing Zeroes. LeetCode258 Add Digits. LeetCode268 Missing Number

    数学题 172. Factorial Trailing Zeroes Given an integer n, return the number of trailing zeroes in n!. N ...

  8. LeetCode 268

    Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one ...

  9. 2017-3-10 leetcode 229 238 268

    今天登陆leetcode突然发现531被锁了,有种占了便宜的感觉哈哈哈! ================================================ leetcode229 Ma ...

随机推荐

  1. ruby -检查json数据类型

    HashObj={","language"=>"zh","make"=>"Apple"," ...

  2. 使用Reaction cli 创建应用

    默认简单跑起来,我们可以直接使用docker,同时官方也为我们提供了cli 工具,可以快速的创建应用 安装cli npm install -g reaction-cli 初始化项目 reaction ...

  3. 时间操作(JavaScript版)—年月日三级联动(默认显示系统时间)

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/wangshuxuncom/article/details/35263317         这个功能 ...

  4. windows10密钥激活方法

    软件设计开发文档模板(国家标准)v1.1.rar 以上就是今天所分享Win10系统各个版本免费激活的windows密钥,希望win10专业版密钥可以帮助大家. 专业版:W269N-WFGWX-YVC9 ...

  5. Linux下的Nginx部署禅道

    基本思路:先安装好nginx和mysql和php,上传禅道的源码.把禅道的源码包扔到 nginx/apache 的工程路径内或者nginx/apache内的配置文件指向nginx的路径,然后将ngin ...

  6. 求幂pow()

    pow(x, n)  求x的n次方. 最简单的方法便是计算n个x相乘 public static double pow(double x, int n) { if (n == 0) return 1; ...

  7. Hanlp中文自然语言处理入门介绍

    自然语言处理定义: 自然语言处理是一门计算机科学.人工智能以及语言学的交叉学科.虽然语言只是人工智能的一部分(人工智能还包括计算机视觉等),但它是非常独特的一部分.这个星球上有许多生物拥有超过人类的视 ...

  8. 【android】 adb logcat命令查看并过滤android输出log

    cmd命令行中使用adb logcat命令查看android系统和应用的log,dos窗口按ctrl+c中断输出log记录. logcat日志中的优先级/tag标记: android输出的每一条日志都 ...

  9. bzoj3326: [Scoi2013]数数

    Description Fish 是一条生活在海里的鱼,有一天他很无聊,就开始数数玩. 他数数玩的具体规则是: 1. 确定数数的进制B 2. 确定一个数数的区间[L, R] 3. 对于[L, R] 间 ...

  10. [转]CSKIN 作者分享的图片处理类

    本代码来自:http://bbs.cskin.net/forum.php?mod=viewthread&tid=113&fromuid=2446 里面没有我想找的任意角度旋转的方法,代 ...