Following is the main function of my program, I could not find any difference between clear() and erase() of vector, then why in following code I am getting diferent results
when I use erase() instead of clear()?

```
 int main()
 {
    int notest, N, temp;
    long long sum, profit;
    int count;

    vector<int> S;
    S.reserve(50009);
    cin>>notest;

    for(int test=0; test<notest; test++)
   {
       profit = 0;
       cin>>N;
    for(int i=0; i<N; i++)
    {
            cin>>temp;
            S.push_back(temp);

    }

    DO SOME THING HERE
    S.clear();      
}

 }

```

Here clear() is not producing the desired results, but when I use erase I get desired results, why?