package ru.job4j.array;

import java.util.Arrays;

/**
*Remove duplicate in array. Task 5.3.
*@author Dmitriy Bobrov (mailto:bobrov.dmitriy@gmail.com)
*@since 0.1
*/
public class ArrayDuplicate {
/**
*Class ArrayDuplicate. Remove duplicate in array.
*/

/**
*inverting array.
*@param array - input array.
*@return array - return array without duplicate.
*/
	public String[] remove(String[] array) {
		int count = 0;
		for (int i = 0; i < array.length - 1; i++) {
            for (int j = i + 1; j < array.length; j++) {
                if (array[i] == null) {
                    i++;
                } else if (array[i].equals(array[j])) {
                    array[j] = null;
                }
            }
        }
		for (int i = 1; i < array.length - 1; i++) {
			if (array[i] == null) {
				array[i] = array[i + 1];
				array[i + 1] = null;
			}
		}
		for (int i = 0; i < array.length; i++) {
			if (array[i] == null) {
				count++;
			}
		}
		return Arrays.copyOf(array, array.length - count);
	}
}
@@ -392,16 +392,28 @@
 rray) %7B%0A
+String tmp;%0A
 %09%09int co
@@ -415,16 +415,18 @@
 nt count
+er
  = 0;%0A%09%09
@@ -452,33 +452,39 @@
  array.length - 
-1
+counter
 ; i++) %7B%0A       
@@ -476,28 +476,19 @@
  i++) %7B%0A
-            
+%09%09%09
 for (int
@@ -519,217 +519,67 @@
 ngth
-; j++) %7B%0A                if (array%5Bi%5D == null) %7B%0A                    i++;%0A                %7D else if (array%5Bi%5D.equals(array%5Bj%5D)) %7B%0A                    array%5Bj%5D = null;%0A                %7D%0A            %7D%0A        %7D%0A
+ - counter; j++) %7B%0A%09%09%09%09if (array%5Bi%5D.equals(array%5Bj%5D)) %7B%0A%09%09%09
 %09%09fo
@@ -589,16 +589,16 @@
 int 
-i = 1; i
+k = j; k
  %3C a
@@ -614,17 +614,17 @@
 th - 1; 
-i
+k
 ++) %7B%0A%09%09
@@ -628,43 +628,40 @@
 %0A%09%09%09
-if (array%5Bi%5D == null) %7B%0A
+%09%09%09tmp = array%5Bk%5D;%0A%09
 %09%09%09%09
+%09
 array%5B
-i
+k
 %5D = 
@@ -662,25 +662,25 @@
 %5Bk%5D = array%5B
-i
+k
  + 1%5D;%0A%09%09%09%09a
@@ -682,23 +682,25 @@
 %09%09%09%09
+%09%09
 array%5B
-i
+k
  + 1%5D = 
 null
@@ -699,105 +699,51 @@
 %5D = 
-null
+tmp
 ;%0A%09%09%09
-%7D%0A
 %09%09%7D%0A%09%09
-for (int i = 0; i %3C array.length; i++) %7B%0A%09%09%09if (array%5Bi%5D == null) %7B%0A%09%09%09%09count++;
+%09%09%09counter++;%0A%09%09%09%09%09j--;%0A%09%09%09%09%7D
 %0A%09%09%09
@@ -798,15 +798,17 @@
  - count
+er
 );%0A%09%7D%0A%7D

Task 5.3 Duplicate array