Codeforces 525A - Vitaliy and Pie

525A - Vitaliy and Pie

思路:贪心+hashing。

代码

#include<bits/stdc++.h>
using namespace std;
string s;
int Hash[]={};
int main()
{
ios::sync_with_stdio(false);
cin.tie();
int n,ans=;
cin>>n>>s;
for(int i=;i<s.size();i++)
{
if(islower(s[i]))
{
Hash[s[i]-'a']++;
}
else
{
if(Hash[s[i]-'A'])Hash[s[i]-'A']--;
else ans++;
}
}
cout<<ans<<endl;
return ;
}
上一篇:正则 匹配 HTML 标签


下一篇:struts2配置的ajax参数传递方法