LintCode:丢失的第一个正整数
来源:互联网 发布:淘宝刷单一单的价格 编辑:程序博客网 时间:2024/06/05 20:56
LintCode:丢失的第一个正整数
Python
from time import sleepclass Solution: # @param A, a list of integers # @return an integer def firstMissingPositive(self, A): # write your code here if len(A) == 0: return 1 m = 0 n = len(A) while m < n: if A[m] == m + 1: m += 1 else: if A[m] >= 0 and A[m] < n and A[m] != A[A[m] - 1]: #A[m], A[A[m] - 1] = A[A[m] - 1], A[m] A[A[m] - 1], A[m] = A[m] ,A[A[m] - 1] else: m += 1 for i in range(n): if A[i] != i + 1: return i + 1 return n + 1
0 0
- LintCode-丢失的第一个正整数
- LintCode 丢失的第一个正整数
- LintCode:丢失的第一个正整数
- LintCode 189-丢失的第一个正整数
- lintcode(189)丢失的第一个正整数
- lintcode -- 丢失的第一个正整数
- Lintcode 丢失的第一个正整数
- 丢失的第一个正整数-LintCode
- LintCode:M-丢失的第一个正整数
- 丢失的第一个正整数——LintCode
- *[Lintcode]First Missing Positive 丢失的第一个正整数
- lintcode刷题——丢失的第一个正整数
- 丢失的第一个正整数
- 丢失的第一个正整数
- 题目:丢失的第一个正整数
- (189)丢失的第一个正整数
- 寻找丢失的第一个正整数
- Java实现-丢失的第一个正整数
- SDAU 练习三 1011 蜜蜂爬巢问题
- 自定义View
- ReentrantLock 源码
- Keepalived实现双机热备
- FPGA:下一代机器人感知处理器
- LintCode:丢失的第一个正整数
- Raspberry Pi如何使用MPU6050
- Codeforces Round #352 (Div. 2) C. Recycling Bottles
- mysql 5.7免安装版步骤
- 怎么在linux下用vim编写一个C程序
- 测试一下
- 《Spark 官方文档》Spark调优
- 通过js 向table添加或修改row及cell
- windows与linux双系统,删除linux分区后,开机进入grub resuce提示符的问题