Help me with analysis of code quality | SoloLearn: Learn to code for FREE!


Help me with analysis of code quality

Hi All, There are two vectors of string. Within vector also, there is a chance of duplicate values. Requirement is to have two vector merged so that result have only unique entries.One sample case is shown as input vector names1 and names2Order of elements in result is not important. I need your help to understand code quality. Can this code be more precise and of improved quality? below is code link:

6/2/2020 12:26:54 PM

Ketan Lalcheta

2 Answers

New Answer


Yes, it is inefficient because you: 1. copy the whole content of both vectors 2. sort the new vector 3. look for iterators that contain duplicate contents 4. delete the iterators These steps are redundant. You might want to look into a container called unordered_set that fits your task perfectly.


Thanks Bobby Fischer ..updated code and could observe the difference in time taken... Thanks a lot 👍