EDIT - Edit Distance Again - SPOJ Solution C++

  Problem Link : EDIT 


👉 Hint : Simple string functions

 


✅ C++ Solution :

 
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char s[1003];
	while(scanf("%s",s)!=EOF)
	{
		int ans1=0,ans2=0;
		for(int i=0;s[i]!='\n';i++)
		{
		    if(!isalpha(s[i]))
		        break;
			if(i%2==0)
			{
				if(isupper(s[i]))
					ans1++;
				if(islower(s[i]))
					ans2++;
			}
			else
			{
				if(isupper(s[i]))
					ans2++;
				if(islower(s[i]))
					ans1++;
			}
		}
		cout<<min(ans1,ans2)<<endl;
	}
}

 

Thank you for your patience reading. If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Whatsapp or Facebook. 

😇Happy Learning!!