OneCompiler

1st question || Problem 1 Complexity: Low

113

/*
Problem 1
Complexity: Low

*/

 #include <bits/stdc++.h>
using namespace std;

int main() 
{
    string s1;
    getline(cin,s1);
    string s2;
    getline(cin,s2);
    string ans = "";
    string temp = "";
    for(int i=0;i<s1.size();i++)
    {
      if(s1[i]==' ')
      {
        if(temp!=s2)
        {
          ans += temp;
          ans += " ";
          
          
        }
        temp = "";
      }
      else{
        temp += s1[i];
      }
      //cout<<temp<<endl;
    }
    if(temp!=s2)
    {
      ans += temp;
    }
    cout<<ans<<endl;
    return 0;
}