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 ...
随机推荐
- ajax状态码
1- AJAX状态值与状态码区别 AJAX状态值是指,运行AJAX所经历过的几种状态,无论访问是否成功都将响应的步骤,可以理解成为AJAX运行步骤.如:正在发送,正在响应等,由AJAX对象与服务器交互 ...
- Eclipse汉化问题解决
1.删除eclipse/configuration 目录下的 org.eclipse.osgi 和org.eclipse.update 两个子目录2.重新启动 eclipse
- Rhel6-hadoop分布式部署配置文档
理论基础: Hadoop 分布式文件系统架构 HDFS 负责大数据存储 MapReduce 负责大数据计算 namenode master守护进程 datanode slaves上负责存储的进程 ...
- Hibernate4 No Session found for current thread原因
Hibernate4 与 spring3 集成之后, 如果在取得session 的地方使用了getCurrentSession, 可能会报一个错:“No Session found for curre ...
- DotNetBar v12.1.0.0 Fully Cracked
更新信息: http://www.devcomponents.com/customeronly/releasenotes.asp?p=dnbwf&v=12.1.0.0 如果遇到破解问题可以与我 ...
- JSON基础使用
1)JSON概念 JSON 是纯文本 JSON 具有“自我描述性”(人类可读) JSON 具有层级结构(值中存在值) JSON 可通过 JavaScript 进行解析 JSON 数据可使用 AJAX ...
- 解决maven Generating project in Interactive mode卡死问题(转)
原文链接:http://blog.csdn.net/only_wan/article/details/52975760 mvn 创建时在generating project in interactiv ...
- SharePoint表单和工作流 - Nintex篇(一)
博客地址 http://blog.csdn.net/foxdave 本篇开始我将带大家去认识一个第三方的表单工作流工具--Nintex. 本篇将对该工具做一些简单的介绍. Nintex公司成立于200 ...
- 转:gartner 2014-07 ETL工具象限排名
ref: http://www.gartner.com/technology/reprints.do?id=1-1YAXV15&ct=140728&st=sb
- jQuery 自定义扩展,与$冲突处理
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...