Problem link
A solution in c++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
using namespace std; | |
/// Typedef | |
typedef long long ll; | |
#define sc1(a) scanf("%lld",&a) | |
#define sc2(a,b) scanf("%lld %lld",&a,&b) | |
#define pf1(a) printf("%lld\n",a) | |
#define pf2(a,b) printf("%lld %lld\n",a,b) | |
#define mx 10000007 | |
#define mod 1000000007 | |
#define PI acos(-1.0) | |
int dr[] = {-2,-2,-1,-1,1,1,2,2}; | |
int dc[] = {-1,1,-2,2,-2,2,-1,1}; | |
int main() | |
{ | |
ll tc, t = 0; | |
//freopen("/opt/Coding/clion code/output.txt", "w", stdout); | |
string arr; | |
cin >> arr; | |
ll ln = arr.size(); | |
stack <char> stk; | |
ll cnt = 0; | |
for(ll i = 0; i < ln; i++){ | |
if(stk.size() and arr[i] == stk.top()){ | |
stk.pop(); | |
cnt++; | |
} | |
else | |
stk.push(arr[i]); | |
} | |
if(cnt % 2 == 1) cout << "Yes" << endl; | |
else cout << "No" << endl; | |
} |
0 Comments
If you have any doubts, Please let me know