shreyya_matade's blog

By shreyya_matade, history, 3 days ago, In English

problem no: 1146A sub id: 128881280 code:

include

include

include

include

include<bits/stdc++.h>

using namespace std;

int main() { string a; int res; cin>>a;

int c=count(a.begin(),a.end(),'a');

int len=a.size(); int val=len-c;

if(val<c) res=val+c; else res=val-c;

cout<<res;

}

 
 
 
 
  • Vote: I like it
  • -24
  • Vote: I do not like it

»
3 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Check if the following update fixes your solution.

if(val<c) res=val+c; else res=2*c-1;