Reduce the array such that each element appears at most 2 times
Given a sorted array arr, remove the duplicates in the array itself such that duplicates appear at most twice in the given array arr and print the new length and modified array arr. Examples: Input: arr[] = {0, 0, 7, 7, 7, 7, 8, 9, 9} Output: 7 arr[] ={0, 0, 7, 7, 8, 9, 9} Explanation: The… Read More »