---
# System prepended metadata

title: L6-Distinct
tags: [Codility_lessons]

---

# L6-Distinct
###### tags: `Codility_lessons`
## Question
https://app.codility.com/programmers/lessons/6-sorting/distinct/
## Key
這題跟leetcode的duplicate integer一樣，都是hash table題目
## Reference
## Solution
```cpp=
#include <algorithm>
#include <set>
int solution(vector<int> &A) {
    set<int> s1;

    for(int i=0; i < A.size(); i++)
    {
        if(s1.count(A[i])==0)   
        {
            s1.insert(A[i]);
        }
    }
    return s1.size();
}
```