268. Missing Number
2016-05-14 16:59
309 查看
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.
Note : Your algorithm should run in linear runtime complexity. Could
you implement it using only constant extra space complexity?
Answer with python:
n, find the one that is missing from the array.
For example, Given nums = [0, 1, 3] return 2.
Note : Your algorithm should run in linear runtime complexity. Could
you implement it using only constant extra space complexity?
Answer with python:
class Solution(object): def missingNumber(self, nums): """ :type nums: List[int] :rtype: int """ length = len(nums) for i in range(0,length): if nums[0] ==0: return 1 else: nums[i] != i return nums[i-1]+1
相关文章推荐
- Canonical和微软在一起了
- 火狐浏览器下 js给img标签赋值:base64编码
- android应用界面编程(四)--ImageView及其子类
- 批量修改文件名的脚本bat\python\shell
- spring factory-method
- Android 拍照或者从相册获取图片的实现
- Android 滑动冲突,事件分发机制的详解
- Fragment使用容易忽视的问题
- MyEclipse8.5破解方法
- 315. Count of Smaller Numbers After Self BST
- 关于解决debian中libpcap>=1.0错误的办法
- 数据结构实验之链表九:双向链表
- TR069协议
- Python中的多进程与多线程/分布式该如何使用
- 在 Linux 中永久修改 USB 设备权限
- <string> 与<string.h>、<cstring>的区别
- context
- python实现SMTP邮件发送功能
- STL next_permutation分析
- Java多线程和并发基础面试问答