leetcode:First Missing Positive
来源:互联网 发布:这个杀手不太冷 知乎 编辑:程序博客网 时间:2024/06/03 14:41
class Solution {public: int firstMissingPositive(int A[], int n) { for(int i =0 ;i < n;i++) { if(A[i]<=n && A[i] > 0) { int temp = A[i]; if(A[i] != A[temp-1]) { A[i] = A[temp-1]; A[temp-1] = temp; i--; } } } int result = 1; for(int i =0 ; i < n;i++) { if(A[i] != result) return result; result++; } return result; }};
0 0
- LeetCode: First Missing Positive
- LeetCode First Missing Positive
- LeetCode: First Missing Positive
- [Leetcode] First Missing Positive
- [LeetCode] First Missing Positive
- [Leetcode] First Missing Positive
- leetcode First Missing Positive
- LeetCode First Missing Positive
- [leetcode] first missing positive
- LeetCode: First Missing Positive
- [LeetCode]First Missing Positive
- LeetCode-First Missing Positive
- [leetcode] First Missing Positive
- [LeetCode] First Missing Positive
- LeetCode - First Missing Positive
- LeetCode | First Missing Positive
- Leetcode: First Missing Positive
- Leetcode:First Missing Positive
- Linux简单命令
- VC++编程之对话框贴图
- error C2653: 'QMessageBox' : is not a class or namespace name
- java判断字符串,为什么用"=="做不了判断,而要用equal()
- string.Template--字符串模板
- leetcode:First Missing Positive
- 关于android webview 调用js
- 数的长度
- Linux系统中的文件目录结构介绍
- org.hibernate.session
- java中并发问题整理
- ASP.NET MVC入门-前言
- cvCopy与cvCloneImage的区别
- aspose.cell 使用总结1 ~~实现单sheet和多sheet功能及表单属性设定