Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void ridOfDoubles(ref int[] arr)
- {
- int count = 0;
- for (int i = 0; i < arr.Length; i++)
- {
- for (int j = 1; j < arr.Length; i++)
- {
- if (arr[i] == arr[j])
- {
- arr[j] = -1; // Marks for deletion
- count++;
- }
- }
- }
- for (int i = 0; i < arr.Length; i++)
- {
- if (arr[i] == -1)
- {
- for (int j = i + 1; j < arr.Length; i++)
- {
- arr[j - 1] = arr[j];
- }
- }
- }
- Array.Resize(ref arr, arr.Length - count);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement