Skip to content

Instantly share code, notes, and snippets.

@probablyangg
Created September 4, 2018 16:59
Show Gist options
  • Save probablyangg/6a94921b64d3c821c03d560eb988315c to your computer and use it in GitHub Desktop.
Save probablyangg/6a94921b64d3c821c03d560eb988315c to your computer and use it in GitHub Desktop.
/* 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