Created
September 4, 2018 16:59
-
-
Save probablyangg/6a94921b64d3c821c03d560eb988315c to your computer and use it in GitHub Desktop.
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
/* Read input from STDIN. Print your output to STDOUT*/ | |
#include <math.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
#include <limits.h> | |
#include <stdbool.h> | |
#include <iostream> | |
#include <string> | |
using namespace std; | |
int journalist (int n, string str) { | |
int count = 0; | |
int left = 0, right = n-1; | |
for(int i=0; i<n/2; i++) { | |
if(str[left] != str[right]) count = count+2; | |
left ++; | |
right --; | |
} | |
return count; | |
} | |
int main(int argc, char *a[]) | |
{ | |
int n; | |
cin>>n; | |
string str; | |
cin>>str; | |
cout<<journalist(n, str); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment