Algorithms
Easy
10031
3236
Smallest Missing Integer Greater Than Sequential Prefix Sum
smallest-missing-integer-greater-than-sequential-prefix-sum
"""
You are given a 0-indexed array of integers nums.
A prefix nums[0..i] is sequential if, for all 1 <= j <= i, nums[j] = nums[j - 1] + 1. In particular, the prefix consisting only of nums[0] is sequential.
Return the smallest integer x missing from nums such that x is greater than or equal to the sum of the longest sequential prefix.

Example 1:

Input: nums = [1,2,3,2,5]
Output: 6
Explanation: The longest sequential prefix of nums is [1,2,3] with a sum of 6. 6 is not in the array, therefore 6 is the smallest missing integer greater than or equal to the sum of the longest sequential prefix.

Example 2:

Input: nums = [3,4,5,1,12,14,13]
Output: 15
Explanation: The longest sequential prefix of nums is [3,4,5] with a sum of 12. 12, 13, and 14 belong to the array while 15 does not. Therefore 15 is the smallest missing integer greater than or equal to the sum of the longest sequential prefix.


Constraints:

1 <= nums.length <= 50
1 <= nums[i] <= 50
"""
class Solution:
    def missingInteger(self, nums: List[int]) -> int:
        
You are given a 0-indexed array of integers nums.
A prefix nums[0..i] is sequential if, for all 1 <= j <= i, nums[j] = nums[j - 1] + 1. In particular, the prefix consisting only of nums[0] is sequential.
Return the smallest integer x missing from nums such that x is greater than or equal to the sum of the longest sequential prefix.

Example 1:

Input: nums = [1,2,3,2,5]
Output: 6
Explanation: The longest sequential prefix of nums is [1,2,3] with a sum of 6. 6 is not in the array, therefore 6 is the smallest missing integer greater than or equal to the sum of the longest sequential prefix.

Example 2:

Input: nums = [3,4,5,1,12,14,13]
Output: 15
Explanation: The longest sequential prefix of nums is [3,4,5] with a sum of 12. 12, 13, and 14 belong to the array while 15 does not. Therefore 15 is the smallest missing integer greater than or equal to the sum of the longest sequential prefix.


Constraints:

1 <= nums.length <= 50
1 <= nums[i] <= 50


Please complete the code below to solve above prblem:
```python
class Solution:
    def missingInteger(self, nums: List[int]) -> int:
        
```

my_solution = Solution()

test_input = { "nums": [1,2,3,2,5] }
assert my_solution.missingInteger(**test_input) == 6

test_input = { "nums": [3,4,5,1,12,14,13] }
assert my_solution.missingInteger(**test_input) == 15

test_input = { "nums": [29,30,31,32,33,34,35,36,37] }
assert my_solution.missingInteger(**test_input) == 297

test_input = { "nums": [19,20,21,22] }
assert my_solution.missingInteger(**test_input) == 82

test_input = { "nums": [18,19,20,21,22,23,24,25,26,27,28,9] }
assert my_solution.missingInteger(**test_input) == 253

test_input = { "nums": [4,5,6,7,8,8,9,4,3,2,7] }
assert my_solution.missingInteger(**test_input) == 30

test_input = { "nums": [38] }
assert my_solution.missingInteger(**test_input) == 39

test_input = { "nums": [1] }
assert my_solution.missingInteger(**test_input) == 2

test_input = { "nums": [11,12,13] }
assert my_solution.missingInteger(**test_input) == 36

test_input = { "nums": [47,48,49,5,3] }
assert my_solution.missingInteger(**test_input) == 144

test_input = { "nums": [23,24,25,4,5,1] }
assert my_solution.missingInteger(**test_input) == 72

test_input = { "nums": [8,9,10,10,7,8] }
assert my_solution.missingInteger(**test_input) == 27

test_input = { "nums": [31,32,33,34,10,8,7,9,7,9,9,5,10,1] }
assert my_solution.missingInteger(**test_input) == 130

test_input = { "nums": [17,18,19,20,21,22,3,7,10,10] }
assert my_solution.missingInteger(**test_input) == 117

test_input = { "nums": [6,7,8,9,10,8,6,7,4,1] }
assert my_solution.missingInteger(**test_input) == 40

test_input = { "nums": [46,8,2,4,1,4,10,2,4,10,2,5,7,3,1] }
assert my_solution.missingInteger(**test_input) == 47

test_input = { "nums": [37,1,2,9,5,8,5,2,9,4] }
assert my_solution.missingInteger(**test_input) == 38

test_input = { "nums": [31,32,33,34,1] }
assert my_solution.missingInteger(**test_input) == 130

test_input = { "nums": [45,46,47,48,49,10,8,1,7,4,10,10,6,6,2] }
assert my_solution.missingInteger(**test_input) == 235

test_input = { "nums": [13,10,7,5,7,10,6,10,2] }
assert my_solution.missingInteger(**test_input) == 14

test_input = { "nums": [32,33,34,35,36,37,38,39,40,41,42,43,44,8,6] }
assert my_solution.missingInteger(**test_input) == 494

test_input = { "nums": [24,8,9] }
assert my_solution.missingInteger(**test_input) == 25

test_input = { "nums": [47,48,49,9,3,8,1,9,2,5,4,5,9] }
assert my_solution.missingInteger(**test_input) == 144

test_input = { "nums": [4,5,6,7,8,9,4,7,10,7,2] }
assert my_solution.missingInteger(**test_input) == 39

test_input = { "nums": [28,29] }
assert my_solution.missingInteger(**test_input) == 57

test_input = { "nums": [40,41,42,3,8,2,7,1,4] }
assert my_solution.missingInteger(**test_input) == 123

test_input = { "nums": [17,18,19,20,21,22,23,24,25,26,27,9,2,5] }
assert my_solution.missingInteger(**test_input) == 242

test_input = { "nums": [43,44] }
assert my_solution.missingInteger(**test_input) == 87

test_input = { "nums": [19,20,5,3,10] }
assert my_solution.missingInteger(**test_input) == 39

test_input = { "nums": [5] }
assert my_solution.missingInteger(**test_input) == 6

test_input = { "nums": [14,15] }
assert my_solution.missingInteger(**test_input) == 29

test_input = { "nums": [47,48,49] }
assert my_solution.missingInteger(**test_input) == 144

test_input = { "nums": [10] }
assert my_solution.missingInteger(**test_input) == 11

test_input = { "nums": [39] }
assert my_solution.missingInteger(**test_input) == 40

test_input = { "nums": [11,12,13,14,15,7,5,2,10,5,6] }
assert my_solution.missingInteger(**test_input) == 65

test_input = { "nums": [3,4,5,7,9,8,1,3,4,9] }
assert my_solution.missingInteger(**test_input) == 12

test_input = { "nums": [29,30,31,32,33,34,35,36,37,38,39,40,41] }
assert my_solution.missingInteger(**test_input) == 455

test_input = { "nums": [24,25,26,27,28,29,30,31,32,33,34,35,6,4,1] }
assert my_solution.missingInteger(**test_input) == 354

test_input = { "nums": [7,8,9,10,11,12,13,14,15] }
assert my_solution.missingInteger(**test_input) == 99

test_input = { "nums": [39,40,41,42,43,44,45,8,10,4] }
assert my_solution.missingInteger(**test_input) == 294

test_input = { "nums": [36,37,6,8] }
assert my_solution.missingInteger(**test_input) == 73

test_input = { "nums": [27,28,29,30] }
assert my_solution.missingInteger(**test_input) == 114

test_input = { "nums": [34,35,5,7] }
assert my_solution.missingInteger(**test_input) == 69

test_input = { "nums": [9,8,6,1] }
assert my_solution.missingInteger(**test_input) == 10

test_input = { "nums": [36,37,38,39,8,10,7] }
assert my_solution.missingInteger(**test_input) == 150

test_input = { "nums": [28,29,6] }
assert my_solution.missingInteger(**test_input) == 57

test_input = { "nums": [14,15,16,17,18,19,20,10,9,10,9,7,3,6] }
assert my_solution.missingInteger(**test_input) == 119

test_input = { "nums": [27,28,29,5] }
assert my_solution.missingInteger(**test_input) == 84

test_input = { "nums": [42,43,44,45,46,47,48] }
assert my_solution.missingInteger(**test_input) == 315

test_input = { "nums": [2,3,4,5,6,7,8,9,10,11,1,10,5,6] }
assert my_solution.missingInteger(**test_input) == 65

test_input = { "nums": [32,33,34,35,36,37,5,8,5,3,4,2,10,3,7] }
assert my_solution.missingInteger(**test_input) == 207

test_input = { "nums": [24,25,26,27,28,29,30,31,32,33,1,3,9] }
assert my_solution.missingInteger(**test_input) == 285

test_input = { "nums": [48,49] }
assert my_solution.missingInteger(**test_input) == 97

test_input = { "nums": [46,47,6,7,1] }
assert my_solution.missingInteger(**test_input) == 93

test_input = { "nums": [32,33,34,35,36,37,38,39,40] }
assert my_solution.missingInteger(**test_input) == 324

test_input = { "nums": [40,41,42,43,44,45,6] }
assert my_solution.missingInteger(**test_input) == 255

test_input = { "nums": [5,6,7,8,9,10,11,12,13,14,15,16,17,18,9] }
assert my_solution.missingInteger(**test_input) == 161

test_input = { "nums": [39,40,41,3,4,7,10,6,2,10,1,9] }
assert my_solution.missingInteger(**test_input) == 120

test_input = { "nums": [17,18] }
assert my_solution.missingInteger(**test_input) == 35

test_input = { "nums": [41,42,43,44,45,46,5,6] }
assert my_solution.missingInteger(**test_input) == 261

test_input = { "nums": [6] }
assert my_solution.missingInteger(**test_input) == 7

test_input = { "nums": [46,47,48,49,50,7] }
assert my_solution.missingInteger(**test_input) == 240

test_input = { "nums": [17,18,19,20,21,22,23,24,25,26,4,7,5,4,4] }
assert my_solution.missingInteger(**test_input) == 215

test_input = { "nums": [40,41,42,43,44,45,46,4,6] }
assert my_solution.missingInteger(**test_input) == 301

test_input = { "nums": [13,4,2,2,3,4,1,8,3,7,7,7,1,6,3] }
assert my_solution.missingInteger(**test_input) == 14

test_input = { "nums": [4,5,6,7,8,9,10,11,12,13,14,15,16,6,8] }
assert my_solution.missingInteger(**test_input) == 130

test_input = { "nums": [12,10] }
assert my_solution.missingInteger(**test_input) == 13

test_input = { "nums": [17,18,19,20,21,5,3,7,10,5,3,7,3,5,3] }
assert my_solution.missingInteger(**test_input) == 95

test_input = { "nums": [38,39,40,41,42,43,44,45,5,7,9,9,4,1] }
assert my_solution.missingInteger(**test_input) == 332

test_input = { "nums": [32,33,34,35] }
assert my_solution.missingInteger(**test_input) == 134

test_input = { "nums": [33,34,7,3,4,4] }
assert my_solution.missingInteger(**test_input) == 67

test_input = { "nums": [33,34,35,36,37,38,39,40,41,42,43,44,45,46,47] }
assert my_solution.missingInteger(**test_input) == 600

test_input = { "nums": [14,9,6,9,7,9,10,4,9,9,4,4] }
assert my_solution.missingInteger(**test_input) == 15

test_input = { "nums": [18,19,20,21,22,23,24,25,26,6,8,2,1] }
assert my_solution.missingInteger(**test_input) == 198

test_input = { "nums": [19,20,21,7,9] }
assert my_solution.missingInteger(**test_input) == 60

test_input = { "nums": [19,20,21,10,1,8,2,1] }
assert my_solution.missingInteger(**test_input) == 60

test_input = { "nums": [1,2,3,9,2,10,8,3,10,2] }
assert my_solution.missingInteger(**test_input) == 6

test_input = { "nums": [48,10] }
assert my_solution.missingInteger(**test_input) == 49

test_input = { "nums": [20,21,22,23,24,25,5] }
assert my_solution.missingInteger(**test_input) == 135

test_input = { "nums": [40,41,42,43,3,4,10,3,7,8,9,1,5] }
assert my_solution.missingInteger(**test_input) == 166

test_input = { "nums": [21,22,23,24,25,26,27,8] }
assert my_solution.missingInteger(**test_input) == 168

test_input = { "nums": [2,3,4,5,6,4] }
assert my_solution.missingInteger(**test_input) == 20

test_input = { "nums": [9,10,11,12,13,14,15,16,17,4] }
assert my_solution.missingInteger(**test_input) == 117

test_input = { "nums": [25,26,27,28,29,6,8] }
assert my_solution.missingInteger(**test_input) == 135

test_input = { "nums": [16,17,18,19,20,21,22,23,24,25,6] }
assert my_solution.missingInteger(**test_input) == 205

test_input = { "nums": [7,8,9,10,11,12] }
assert my_solution.missingInteger(**test_input) == 57

test_input = { "nums": [32,9,2,6,4,1,4,3,5] }
assert my_solution.missingInteger(**test_input) == 33

test_input = { "nums": [1,4,3] }
assert my_solution.missingInteger(**test_input) == 2

test_input = { "nums": [34,35,36,37,38,39,1,9,3,3,10,7,1] }
assert my_solution.missingInteger(**test_input) == 219

test_input = { "nums": [37,7,6,4,3,1,10,8,7,2,6] }
assert my_solution.missingInteger(**test_input) == 38

test_input = { "nums": [32] }
assert my_solution.missingInteger(**test_input) == 33

test_input = { "nums": [25,26,27,4] }
assert my_solution.missingInteger(**test_input) == 78

test_input = { "nums": [31,32,33,8,5,3,7,2] }
assert my_solution.missingInteger(**test_input) == 96

test_input = { "nums": [38,39,40,41,42,43,44,45,1] }
assert my_solution.missingInteger(**test_input) == 332

test_input = { "nums": [35,36,3,10] }
assert my_solution.missingInteger(**test_input) == 71

test_input = { "nums": [31,32,33,34,35,7,6,1,9] }
assert my_solution.missingInteger(**test_input) == 165

test_input = { "nums": [47,48,49,2,2] }
assert my_solution.missingInteger(**test_input) == 144

test_input = { "nums": [3,4,5,6,7,8,9,10,11,10,1] }
assert my_solution.missingInteger(**test_input) == 63

test_input = { "nums": [50] }
assert my_solution.missingInteger(**test_input) == 51

test_input = { "nums": [14,15,16,17,7,10,3,10] }
assert my_solution.missingInteger(**test_input) == 62