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的更多相关文章

  1. &lt;LeetCode OJ&gt; 268. Missing Number

    268. Missing Number Total Accepted: 31740 Total Submissions: 83547 Difficulty: Medium Given an array ...

  2. 【LeetCode】268. Missing Number

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

  3. 268. Missing Number@python

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

  4. Java [Leetcode 268]Missing Number

    题目描述: Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is ...

  5. [LeetCode] 268. Missing Number ☆(丢失的数字)

    转载:http://www.cnblogs.com/grandyang/p/4756677.html Given an array containing n distinct numbers take ...

  6. 268. Missing Number序列中遗失的数字

    [抄题]: Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is ...

  7. 268. Missing Number -- 找出0-n中缺失的一个数

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

  8. 33. leetcode 268. Missing Number

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

  9. LeetCode 268. Missing Number (缺失的数字)

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

随机推荐

  1. C#解析Json(多方法解析Json 一)

    解析:{'id':'4028d80858053bed0158053ef7a50001','sl':0.0,'sfyfz':'0','zwjyzsbh':'1000001600000018'} 1.新建 ...

  2. C#编程

    C#最完整的webservice实例 http://fyinthesky.blog.163.com/blog/static/3555251720110115227337/ C# WinForm 实践开 ...

  3. 使用 JDBC 调用函数 & 存储过程

    /** * 如何使用 JDBC 调用存储在数据库中的函数或存储过程 */ @Test public void testCallableStatment() { Connection connectio ...

  4. POJ 1741 树上的点分治

    题目大意: 找到树上点对间距离不大于K的点对数 这是一道简单的练习点分治的题,注意的是为了防止点分治时出现最后分治出来一颗子树为一条直线,所以用递归的方法求出最合适的root点 #include &l ...

  5. 踏着前人的脚印学hadoop——ipc中的Client

    1.Client有五个内部类,分别是Call,ParallelCall,ParallelResult,Connetion,ConnectionId 其实这五个类就是去完成两件事情的,一件事情是连接,另 ...

  6. @ResultMapping注解

    @RequestMapping注解1.url映射放在方法上:@RequestMapping("/itemsEdit")2.窄化url请求映射放在类上,定义根路径,url就变成根路径 ...

  7. iPhone 6/6 Plus国行版开卖当日抢购攻略

    在距离苹果首批发售时隔一个月也就是北京时间10月17日,苹果iPhone 6.iPhone 6 Plus终于也要在中国大陆开卖,众多国内用户终于有机会安排自己的购机计划.据不完全数据显示,目前iPho ...

  8. java基础-005

    27.Java中垃圾回收的目的及回收的时机 垃圾回收的目的是识别并且丢弃不再使用的对象来释放和重用资源. 如果对象的引用被置为null,垃圾收集器不会立即释放对象占用的内存. 什么时候进行垃圾回收,主 ...

  9. MySQL的高级查询

    高级查询 1.连接查询(对列的扩展) 第一种形式select * from Info,Nation #会形成笛卡尔积 select * from Info,Nation where Info.Nati ...

  10. java classpath深入详解(转)

    http://developer.51cto.com/art/200509/2786.htm 设置类路径 结构 可通过对 JDK 工具使用 -classpath 选项(首选方法)或设置 CLASSPA ...