Different approaches for checking whether Array has duplicate elements or not

This is one of basic searching algorithm question.
In this post, we’ll look into different approaches of checking whether array has duplicate elements or not. In addition to this, we’ll also see how to findall duplicate elements from array in one pass.

Approach 1 Brute-Force approach
In this method, for each input elements check whether there is any element with the same value. This we can solve with two loops.

Time Complexity : O(n^2) for nested loops, Space Complexity : O(1)

Click here to read more

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s