In a language of your choice, please provide a solution for the following problem.
Problem:
Given a sorted array of non-zero integers, remove the duplicate elements from the array and return the number of unique elements found.
At the end of your algorithm, the array should contain unique elements. If the number of unique elements is less than the size of the array, fill the remaining indices with 0. For example:
ex. Input - arr[] = {1, 2, 2, 3}
ex. Output - arr[] = {1, 2, 3, 0} - return 3
ex. Input - arr[] = {1, 1, 1, 1}
ex. Output - arr[] = {1, 0, 0, 0} - return 1
You should include your algorithm in the removec Duplicates method, whose inputs are the array and the length of the array.