the logic i used: after the user enters the string, i found the length of string using strlen().
then i checked every element with its next element and checked if it was a pair or not.
if it was a pair, i increemented count by 1 and also incremented loop counter by 1 so that the next element does not get checked again since it has already formed a pair with its previous element.
this code was like:
if(arr[i]==‘x’ && arr[i+1]==‘y’)
else if(arr[i]==‘y’ && arr[i+1]== ‘x’)
note: the codechef ide gave incorrect answers but when i ran it on my codeblocks (using gnu compiler) i got correct answers.
thank you for your help
and sorry if i am missing something obvious