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 ...
随机推荐
- idea快捷键 好的网址收藏
http://blog.csdn.net/u010800804/article/details/48491395http://blog.csdn.net/wei83523408/article/det ...
- 1920*1080分辨率和1080p,1080i的关系
1080i和1080p是由美国电影电视工程师协会确定的高清标准格式,其中1080p被称为目前数字电视的顶级显示格式,这种格式的电视在逐行扫描下能够达到1920×1080的分辨率.受限制于存储介质(一部 ...
- leetcode:Palindrome Number【Python版】
一次AC 题目要求中有空间限制,因此没有采用字符串由量变向中间逐个对比的方法,而是采用计算翻转之后的数字与x是否相等的方法: class Solution: # @return a boolean d ...
- Vault 0.10包含了web ui
Vault 是一个很不错的访问控制,secret api key 管理工具 新的0.10 有好多新的功能的添加,最棒的是有一个web ui 了 包含的新特性如下: K/V Secrets Engine ...
- bzoj 3528 [ZJOI2014] 星系调查 题解
[原题] 星系调查 [问题描写叙述] 银河历59451年.在银河系有许很多多已被人类殖民的星系.如果想要在行 星系间往来,大家一般使用连接两个行星系的跳跃星门. 一个跳跃星门能够把 物质在它所连接的 ...
- Aria2+yaaw+Chrome插件BaiduExporter实现百度网盘下载
Aria2+yaaw+Chrome插件BaiduExporter实现百度网盘下载 这篇博客主要为了解决百度网盘下载限速以及linux等操作系统无百度客户端的问题.主要包括两个方面第一个是aria2的安 ...
- JVM监控
jconsole 说明: 首先JConsole这个是JDK里面自带的工具 在JAVA_HOME/bin目录下,今天主要测试远程监控JVM 第一步:设置好需要远程机器的Tomcat 修改Tomcat下 ...
- 服务检测sh脚本
如mysql cat check_mysql.sh #!/bin/bash servicename="mysqld"showname="mysql" pid=& ...
- Angular 4 依赖注入
一.依赖注入 1. 创建工程 ng new myangular 2. 创建组件 ng g componet product1 3. 创建服务 ng g service shared/product 如 ...
- golang 自定义类型的排序sort
sort包中提供了很多排序算法,对自定义类型进行排序时,只需要实现sort的Interface即可,包括: func Len() int {... } func Swap(i, j int) {... ...