You are given a 0-indexed integer array nums.
The prefix of the array is considered sequential if:
For every index j from 1 to i,
nums[j] = nums[j - 1] + 1.
A single-element prefix (only nums[0]) is always considered sequential.
Your task is to:
Identify the longest sequential prefix of the array.
Calculate the sum of all elements in that prefix.
Return the smallest missing integer in the array that is greater than or equal to this sum.
👉 Output: Return the first missing integer in the array that is ≥ the sum of the longest sequential prefix.
Input: nums = [4,5,6,10,11]
Output: 15
Explanation:
Longest sequential prefix = [4,5,6] Sum = 4 + 5 + 6 = 15 Array me 15 nahi hai → answer = 15
Input: nums = [2,3,4,7,8,9]
Output: 10
Explanation:
Sequential prefix = [2,3,4] Sum = 9 9 present hai → next number 10 10 not present → answer = 10
Accepted:
Submission: