| 2 | using namespace std; |
| 3 | |
| 4 | int main(){ |
| 5 | int n, con=0; |
| 6 | cin >> n; //length of the strings a and b. |
| 7 | string a, b; |
| 8 | int c[n]; |
| 9 | |
| 10 | cin >> a >> b; |
| 11 | |
| 12 | for(int i=0; i<n-1; i++){ |
| 13 | if(a[i]!=b[i]){ //if ai and bi are different, check if the i+1 of each one is different or equal |
| 14 | if(a[i+1]==b[i+1]) con++; //if they are the same it will not be possible to exchange |
| 15 | else{ |
| 16 | if(a[i]!=a[i+1]){ //if ai is different from ai+1 they switch places with each other |
| 17 | swap(a[i], a[i+1]); |
| 18 | con++; |
| 19 | } |
| 20 | else con++; |
| 21 | } |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | if(a[n-1]!=b[n-1]) con++; //checks whether the last strings are the same or not |
| 26 | |
| 27 | cout << con; |
| 28 | |
| 29 | return 0; |
| 30 | } |
nothing calls this directly
no outgoing calls
no test coverage detected