Skip to content

Commit 5a15b5f

Browse files
41. First Missing Positive (java)
1 parent cb2ebc6 commit 5a15b5f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Solution {
2+
public int firstMissingPositive(int[] nums) {
3+
int re = 1;
4+
Arrays.sort(nums);
5+
for (int num : nums) {
6+
if (num == re) re++;
7+
if (num > re) return re;
8+
}
9+
return re;
10+
}
11+
}

0 commit comments

Comments
 (0)