Skip to content

Commit fbb36e7

Browse files
committed
leetcode_solved/leetcode_0041_First_Missing_Positive.cpp
1 parent e4421bf commit fbb36e7

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

leetcode_solved/[editing]leetcode_0041_First_Missing_Positive.cpp

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Runtime: 4 ms, faster than 53.27% of C++ online submissions for First Missing Positive.
3+
* Memory Usage: 9.7 MB, less than 6.00% of C++ online submissions for First Missing Positive.
4+
*/
5+
class Solution {
6+
public:
7+
int firstMissingPositive(vector<int>& nums) {
8+
int size = nums.size();
9+
int currentSmallest = 1;
10+
11+
while (1) {
12+
for (int i = 0; i < size; i++) {
13+
if (nums[i] == currentSmallest) {
14+
currentSmallest++;
15+
break;
16+
}
17+
}
18+
return currentSmallest;
19+
}
20+
}
21+
};

0 commit comments

Comments
 (0)