Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp10
- {
- public class RemoveDuplicatesSort
- {
- public void Remove(int[] array)
- {
- if (array == null)
- {
- throw new ArgumentException("Array is empty");
- }
- Array.Sort(array);
- int j = 0;
- for (var i = 0; i < array.Length; i++)
- {
- if (i == array.Length - 1 || array[i] != array[i + 1])
- {
- array[j++] = array[i];
- }
- }
- while (j < array.Length)
- {
- array[j++] = -1;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement