Three line codes can solve this question


  • -2
    T

    class Solution {
    public:
    int firstMissingPositive(vector<int>& nums) {
    for (int i = 1; i < INT_MAX;i++)
    {
    if (find(nums.begin(),nums.end(),i)==nums.end())
    {
    return i;
    }
    }
    return INT_MAX;
    }
    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.