➤ Problem Link : 343B. Alternating Current
✅ C++ Solution :
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
string s;
cin>>s;
string t="@";
for(int i=0;i<s.length();i++)
{
if(s[i]==t.back())
t.pop_back();
else
t.push_back(s[i]);
}
if(t=="@")
cout<<"Yes";
else
cout<<"No";
}
Thank you for your patience reading. If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Whatsapp or Facebook.
😇Happy Learning!!
