123456789101112 |
- /* Given an array of numbers, write a function that returns an array that...
- Has all duplicate elements removed.
- Is sorted from least value to greatest value.
- */
- std::vector<int> uniqueSort(std::vector<int> arr) {
- std::sort(arr.begin(),arr.begin()+arr.size());
- std::vector<int>::iterator i = std::unique (arr.begin(), arr.end());
- arr.resize(std::distance (arr.begin(),i));
- return arr;
- }
|