Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Duplicates from Array using C++ #366

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Prime-5
Copy link

@Prime-5 Prime-5 commented Oct 5, 2019

Please describe your program and how to run it.

A C++ solution to #323 (Removes duplicate elements)


What Programming Language?

C++

for (auto i=v.begin(); i!=v.end(); i++) //Remove duplicates
{ for(auto j=i+1;j!=v.end();j++)
{ if(*i==*j)
{ v.erase(j); j--; }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v.erase(j--) ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that shortens the code. Now there is no need for braces coz it's a single statement. Sweet!

@wzhouwzhou wzhouwzhou added Change Requested Please see the reviewer(s)' comments for more information Lang: C++ Contributions made in C Plus Plus labels Oct 5, 2019
Copy link
Owner

@wzhouwzhou wzhouwzhou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine now

@wzhouwzhou wzhouwzhou added hacktoberfest-accepted Hacktoberfest! and removed Change Requested Please see the reviewer(s)' comments for more information labels Oct 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted Hacktoberfest! Lang: C++ Contributions made in C Plus Plus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants