only 10 lines java code


  • 0
    W
    public class Solution {
        public int firstMissingPositive(int[] nums) {
            int ret = 1;
            while(true){
                int i =0;
                for(; i < nums.length; i++){
                    if(nums[i] - ret == 0)
                        break;
                }
                if( i == nums.length)
                    return ret;
                ++ret;
            }
        }
    }
    

Log in to reply
 

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