268. Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.
For example,
Given nums = [0, 1, 3] return 2.
代码如下:
public class Solution {
public int missingNumber(int[] nums) {
Arrays.sort(nums);
for(int i=0;i<nums.length;i++)
{
if(nums[i]!=i)
return i;
}
return nums.length;
}
}
268. Missing Number的更多相关文章
- <LeetCode OJ> 268. Missing Number
268. Missing Number Total Accepted: 31740 Total Submissions: 83547 Difficulty: Medium Given an array ...
- 【LeetCode】268. Missing Number
Missing Number Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one ...
- 268. Missing Number@python
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missin ...
- Java [Leetcode 268]Missing Number
题目描述: Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is ...
- [LeetCode] 268. Missing Number ☆(丢失的数字)
转载:http://www.cnblogs.com/grandyang/p/4756677.html Given an array containing n distinct numbers take ...
- 268. Missing Number序列中遗失的数字
[抄题]: Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is ...
- 268. Missing Number -- 找出0-n中缺失的一个数
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missin ...
- 33. leetcode 268. Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missin ...
- LeetCode 268. Missing Number (缺失的数字)
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missin ...
随机推荐
- POJ 3299 Humidex 难度:0
题目链接:http://poj.org/problem?id=3299 #include <iostream> #include <iomanip> using namespa ...
- POJ 2771 二分图(最大独立集)
Guardian of Decency Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 5244 Accepted: 21 ...
- 其他窗体赋值给comboBox实现值的回显,并使赋的值处于选中状态(根据text获取selectedindex)
Form1 发货单位的这个下拉框comboBox1已经绑定数据库test表的name字段,里面有很多单位名称 比如有:甲公司.乙公司... 1.Form1的comboBox1首先绑定数据库的数据表te ...
- not use jquery
document.getElementById('myElement');document.querySelector('#myElement'); document.getElementsByCla ...
- redis2.8--主从机同步流程
- 踏着前人的脚印学Hadoop——序列化,Writerable
package org.apache.hadoop.io; import java.io.DataOutput;import java.io.DataInput;import java.io.IOEx ...
- idea快捷键(转)
Ctrl+/ 或 Ctrl+Shift+/ 注释(// 或者/*...*/ )Ctrl+D 复制行Ctrl+X 删除行快速修复 alt+enter (modify/cast)代码提示 alt+/ctr ...
- 元素ID命名规范
因为本框架默认所有内容都位于一个Document中,所以为元素命名为ID的时候需要做到唯一性,如果确实不可避免的会出现有重读ID的现象,需要操作当前页片(页面片段,就是子页面)的时候,尽量用: $.C ...
- SharePoint 2013 Nintex Workflow 工作流帮助(十)
博客地址 http://blog.csdn.net/foxdave 工作流动作 23. Create appointment(企业版才有) 该操作用于在Microsoft Exchange中创建一个商 ...
- 面向对象之prototype,__proto__
var person = function(name) { this.name = name }; person.prototype.getName = function() { return thi ...