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. java8 array、list操作 汇【2】)- (Function,Consumer,Predicate,Supplier)应用

    static class UserT { String name; public UserT(String zm) { this.name=zm; } public String getName() ...

  2. (转)C语言中scanf函数与空格回车

    来源:http://blog.csdn.net/xia7139/article/details/14522493

  3. YUV和RGB之间的转换方法

    yCbCr<-->rgb Y’ = 0.257*R' + 0.504*G' + 0.098*B' + 16 Cb Cr R) G) - 0.392*(Cb'-128) B) 参考: htt ...

  4. Make menuconfig生成文件

    1.当我们在执行make menuconfig这个命令时,一共涉及到了以下几个文件: Linux内核根目录下的scripts文件夹 arch/$ARCH/Kconfig文件.各层目录下的Kconfig ...

  5. vulcanjs 开源工具方便快速开发react graphql meteor 应用

    vulcan 开源工具方便快速开发react graphql meteor 应用 操作环境mac os 安装 meteor 安装(此安装有点慢,可以通过正确上网解决) curl https://ins ...

  6. 如何构建 MVC&AJax&JSon示例

    背景: 博客中将构建一个小示例,用于演示在ASP.NET MVC4项目中,如何使用JQuery Ajax. 直接查看JSon部分 步骤: 1,添加控制器(HomeController)和动作方法(In ...

  7. JS 得细心的坑位

    <script> function test(link) { link = link || 'none'; alert(link); } function test2(){ var lin ...

  8. Angular 4 绑定

    一.事件绑定 1. 创建doOnClick函数 2. 网页中绑定doOnClick方法 3. 效果图 二. 属性绑定 1. 定义imgUrl的网址 2. 定义img  src属性 另外一种写法 3. ...

  9. [数据结构与算法] : AVL树

    头文件 typedef int ElementType; #ifndef _AVLTREE_H_ #define _AVLTREE_H_ struct AvlNode; typedef struct ...

  10. PHP版本VC6与VC9/VC11/VC14、Thread Safe与None-Thread Safe等的区别

    最近正好在弄一个PHP的程序,在这之前一直没有怎么以接触,发现对PHP版本知识了解不是很清楚,自己看了不少类似的文章,还是感觉不够明确和全面, 网上的结论又都是模棱两可,在此,给出最完整甚至武断的解释 ...