Question 4

Remove the duplicate elements in an integer array

Algorithm:

  1. Create an empty LinkedHashSet
  2. Loop(iterate) the input array till there are elements
  3. Add the iterated elements into the set
  4. End the loop
  5. Convert the set to an output array
  6. Print the output array

Example:

Input: {1,4,5,8,5,2}(Array)

Output:{1,4,5,8,2}(Array)

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s