Given an array and a value, remove all instances of that value in-place and return the new length. A sorted-style adjacent group scan works well when matching values are easy to compress.
nums = array of integers, val = value to remove
new length after removal
Example 1:
Input:
nums = [3,2,2,3] val = 3
Output:
2
Explanation:
The remaining prefix can be [2,2].
Example 2:
Input:
nums = [0,1,2,2,3,0,4,2] val = 2
Output:
5
Explanation:
All 2s are removed and the remaining values are compacted.