Please anybody who have solved Banana String tell me the approach to solve Banana String Problem.

Banana String

please

Editorial will be available soon.

Just finishing up the editorial will be available in less than an hour or so.

Please upload editorial.

It has long been uploaded

Thanks bro

could any one tell me whatβs the problem in my approach?

#include <bits/stdc++.h>

using namespace std;

//scanf(" %[^\n]s",s);

int str2int (const string &str) {

stringstream ss(str);

int num;

ss >> num;

return num;

}

int main()

{

int t;

cin>>t;

while(t>0,tβ)

{

int n,p;

cin>>n>>p;

char arr[n],brr[n];

for(int i=0;i<n;i++)

{

cin>>arr[i];

brr[i] = arr[i];

}

```
sort(brr, brr+n);
int count = 0;
for(int i=0;i<n;i++)
{
if(arr[i] != brr[i]){
count++;
}
}
int tillTotal = count/2;
p = p - tillTotal;
```

// cout<<" tillTotal = β<<tillTotal<<endl;

if( p > 0 && p%2 == 0)

{

// cout<<β p = "<<p<<endl;

for(int i=0;i<n-1 && p>0 ;i++ )

{

if(brr[i] != brr[i+1])

{

brr[i+1] = βaβ;

p = p - 2;

}

}

for(int i=0;i<n;i++ )

{

cout<<brr[i];

}

cout<<endl;

```
}else{
for(int i=0;i<n;i++)
{
cout<<brr[i];
}
cout<<endl;
}
}
```

}