<awangdev>41. First Missing Positive_1.java
public int firstMissingPositive(int[] nums) {
        if (nums == null || nums.length == 0) {
            return 1;
        }
        if (nums.length == 1) {
            return nums[0] == 1 ? 2 : 1;
        }
        int n = nums.length;
        int i = 0;
        while (i < n) {
            int val = nums[i];
            if (val != i && val >= 0 && val < n && val != nums[val]) { 
                int temp = nums[val];
                nums[val] = nums[i];
                nums[i] = temp;
            } else {
                i++;
            }
        }

        for (i = 1; i < n; i++) {
            if (nums[i] != i) {
                return i;
            }
        }
        
        if (nums[0] == n) {
            return n + 1;
        }

        return n;
    }
public int sample_funcname ( int [ ] var_0 ) {
  if ( var_0 == null || var_0 . length == 0 ) {
    return 1 ;
  }
  if ( var_0 . length == 1 ) {
    return var_0 [ 0 ] == 1 ? 2 : 1 ;
  }
  int var_6 = var_0 . length ;
  int var_7 = 0 ;
  while ( var_7 < var_6 ) {
    int var_8 = var_0 [ var_7 ] ;
    if ( var_8 != var_7 && var_8 >= 0 && var_8 < var_6 && var_8 != var_0 [ var_8 ] ) {
      int var_9 = var_0 [ var_8 ] ;
      var_0 [ var_8 ] = var_0 [ var_7 ] ;
      var_0 [ var_7 ] = var_9 ;
    }
    else {
      var_7 ++ ;
    }
  }
  for ( var_7 = 1 ;
  var_7 < var_6 ;
  var_7 ++ ) {
    if ( var_0 [ var_7 ] != var_7 ) {
      return var_7 ;
    }
  }
  if ( var_0 [ 0 ] == var_6 ) {
    return var_6 + 1 ;
  }
  return var_6 ;
}
