We have provided the Java program below, which is designed to find the first missing value in an integer array where the sequence starts from 1. The array may contain values up to a maximum of 10,000. This program checks for the first missing number by comparing each element in the array with the expected sequence value.
For this challenge, we have intentionally removed one required statement from the program. Your task is to identify and comment on the missing statement. Click on “Solution” to view the correct line of code that should be added.
import org.testng.annotations.Test;
public class SampleProgram4{
@Test
public void testMySkills() {
System.out.println(findMissingNumber());
}
public int findMissingNumber() {
int[] nums = {1, 2, 3, 4, 5, 6};
int i = 0;
int len = nums.length;
int seq = 1;
while(i<len) {
if(nums[i] !=seq){
return seq;
}
i++;
}
return seq;
}
}