leetcode268
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的更多相关文章
- Leetcode-268 Missing Number
#268. Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find ...
- [Swift]LeetCode268. 缺失数字 | Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missin ...
- leetcode268缺失数字
int missingNumber(int* nums, int numsSize) { ) /; ;i<numsSize;i++){ sum = sum - nums[i]; } return ...
- [leetcode268]Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missin ...
- LeetCode268.缺失数字
268.缺失数字 描述 给定一个包含 0, 1, 2, ..., n 中 n 个数的序列,找出 0 .. n 中没有出现在序列中的那个数. 示例 示例 1: 输入: [3,0,1] 输出: 2 示例 ...
- leetcode268:Missing Number
描写叙述 Given an array containing n distinct numbers taken from 0, 1, 2, -, n, find the one that is mis ...
- 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 ...
- LeetCode 268
Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one ...
- 2017-3-10 leetcode 229 238 268
今天登陆leetcode突然发现531被锁了,有种占了便宜的感觉哈哈哈! ================================================ leetcode229 Ma ...
随机推荐
- dfs 与 剪枝
http://blog.csdn.net/u010700335/article/details/44095171
- freemarker逻辑判断写法#if
<li class="<#if (position.flag)! =='haha1'>hide<#else >show</#if>"> ...
- 【C#】 增加多个分部类
有时需要在一个类下面增加多个不同功能的分部类,或者是不同开发组员以其命名的分部类. eg: 首先创建一个类,改为分部类,partial.. 复制此类的文件,改一个文件名.然后修改项目文件.csproj ...
- 玩转ptrace (一)
转自http://www.cnblogs.com/catch/p/3476280.html [本文翻译自这里: http://www.linuxjournal.com/article/6100?pag ...
- centos下yum安装pip失败
[root@wfm ~]# yum -y install pip Loaded plugins: fastestmirror, refresh-packagekit, securityLoading ...
- echarts 知识点
echarts map 禁止放大缩小,设置 calculable 为 false 即可. calculable: false echarts 报错: There is a chart instance ...
- FineUI导出Excel
1.[经验分享]导出Excel的乱码问题http://www.fineui.com/bbs/forum.php?mod=viewthread&tid=6326&highlight=Ex ...
- java 物理资源回收 finally与try
java垃圾回收机制不会回收任何物理资源(磁盘文件.数据库连接.网络连接),垃圾回收机制只能回收堆内存中对象所占用的内存. 方法一使用finally块,在finally块中写入资源回收代码,如下: p ...
- MySQL主从同步和半同步配置
mysql主从配置: 1,安装maraidb,使用国内yum镜像站下载:[root@localhost mysql]# cat /etc/yum.repos.d/MairaDB.repo # Mari ...
- JavaScript-Tool:Numeral.js
ylbtech-JavaScript-Tool:Numeral.js A javascript library for formatting and manipulating numbers. 1. ...