0

I am getting this error on an online judge:

no matching function for call to 'find(std::vector<char>::iterator, std::vector<char>::iterator, __gnu_cxx::__alloc_traits<std::allocator<char> >::value_type&)'
      it=find(s.begin(),s.end(),words[i]);

What is my mistake?

This is my code-

  #include<iostream>
  using namespace std;
  #include<vector>


  int main()
  {
      string guest,host,words;
      cin>>guest>>host>>words;
      vector<char>s;
      vector<char>::iterator it;
      for(int i=0;i<guest.length();i++)
      {
        s.push_back(guest[i]);
      }
      for(int i=0;i<host.length();i++)
      {
        s.push_back(host[i]);
      }

      for(int i=0;i<words.length();i++)
      {
        it=find(s.begin(),s.end(),words[i]);

        if(it!=s.end())
        {
          s.erase(it);
        }
        else{

           cout<<"NO";
           return 0;
        }
      }
      cout<<"YES";
      return 0;
  }
1201ProgramAlarm
  • 32,384
  • 7
  • 42
  • 56
  • 1
    You need to `#include `. – Lukas-T May 24 '20 at 19:05
  • 1
    Congratulations! You are caught by using this bad practice https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice – 273K May 24 '20 at 19:08
  • 1
    Also `#include ` is missing. – PaulMcKenzie May 24 '20 at 19:12
  • @S.M. • I need to finish my "deader files" project. Header files that provide ONLY the required identifiers and nothing more (and no implementation, so its only compile-able and not link-able), and no indirect includes. Inspired by P.J.Plauger & Dinkumware, of course. (But `constexpr` is probably going to be a wrench in my plans.) – Eljay May 24 '20 at 19:12
  • `std::string s(guest.begin(), guest.end());` -- No need for a loop to set the `s` vector. You also don't need a loop to attach the `host` string to the vector. Use `vector::insert()`. – PaulMcKenzie May 24 '20 at 19:14

0 Answers0