Opening Hours :7AM to 9PM
import java.util.Arrays; import java.util.LinkedHashSet; class RemoveDuplicates { public int[] removeDuplicates(int[] nums) { // LinkedHashSet preserves the insertion order and removes duplicates LinkedHashSet<Integer> set = new LinkedHashSet<>(); for (int i : nums) { set.add(i); } int[] uniqueNums = new int[set.size()]; int i = 0; for (int n : set) { uniqueNums[i++] = n; } return uniqueNums; } } public class Main { public static void main(String[] args) { RemoveDuplicates rm=new RemoveDuplicates(); int[] nums = {1, 2, 3, 4, 4, 5, 6, 7, 8, 8, 9}; int[] uniqueNums = rm.removeDuplicates(nums); System.out.println("Original Array : " + Arrays.toString(nums)); System.out.println("Unique Array : " + Arrays.toString(uniqueNums)); } }This program uses a LinkedHashSet to remove duplicates from the input array. A LinkedHashSet is a special type of HashSet that preserves the insertion order of elements. This means that the order of elements in the input array is preserved in the output array.