shreyya_matade's blog

By shreyya_matade, history, 6 weeks 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;

}

Read more »

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

By shreyya_matade, history, 6 weeks ago, In English

problem: 310 A Case of Zeroes and Ones sub id: 128701541 code :

include

using namespace std; int main() { int n; int c=0; cin>>n;

char a[n];
for(int i=0;i<n;i++)
{
    cin>>a[i];
}
for(int i=0;i<n;i++)
{
    if(a[i]=='0')
    {
        c++;
    }
}
int val=n-c*2;
int res=abs(val);
cout<<res;

}

Read more »

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

By shreyya_matade, history, 6 weeks ago, In English

How do i solve the memory exceeded problem here according to my code? problem no:318 A Even and odds sub id: 128562778 code:

include

include

include

include

include<bits/stdc++.h>

using namespace std; int main() { int n; int k;

cin>>n>>k;

vector v1; vector v2;

for(int i=1;i<=n;i++) { if(i%2!=0) { v1.push_back(i); } else if(i%2==0) { v2.push_back(i); } } int len1=v1.size();

if(k<=len1) cout<<v1[k-1]; else if(k>len1) cout<<v2[k-5];

}

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it