Remove Duplicates from Sorted Array II

Given a non-decreasing array of integers, return a new array where each value appears at most twice.

Examples
Input: [1,1,1,2,2,3]
Output: [1,1,2,2,3]
Hints

Remove Duplicates from Sorted Array II

Given a non-decreasing array of integers, return a new array where each value appears at most twice.