Below code is for finding least missing positive number and it is correctly implemented

but i have a doubt let me explain by a sample input

5

-4 -3 -2 1 2

It’s Correct Output should be 3

But before getting the final code my previous code was giving Output 5

which is why i added line no. 35 Because in the case when we have complete positive series which is incremented by 1 then My code doesn’t return any value

Link For code

So my question is If On simmilar cases if we have complete positive series why it is returning the value of n

```
int solve(int arr[], int n)
{
sort(arr, arr + n);
int i = 0, track = 1;
while (arr[i] != 1 && i < n) // to skip -ve no.s and 0
i++;
if (i == n)
return 1;
while (i < n)
{
if (arr[i] == track)
{
track++;
while (arr[i] != track && i < n) // for handling duplicates
{
if (arr[i] > track)
return track;
i++;
}
}
else
{
return track;
}
}
// return track;
}```
```