题干:

Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string sconsisting only of lowercase and uppercase Latin letters.

Let A be a set of positions in the string. Let's call it pretty if following conditions are met:

  • letters on positions from A in the string are all distinct and lowercase;
  • there are no uppercase letters in the string which are situated between positions from A (i.e. there is no such j that s[j] is an uppercase letter, and a1 < j < a2 for some a1 and a2 from A).

Write a program that will determine the maximum number of elements in a pretty set of positions.

Input

The first line contains a single integer n (1 ≤ n ≤ 200) — length of string s.

The second line contains a string s consisting of lowercase and uppercase Latin letters.

Output

Print maximum number of elements in pretty set of positions for string s.

Examples

Input

11
aaaaBaabAbA

Output

2

Input

12
zACaAbbaazzC

Output

3

Input

3
ABC

Output

0

Note

In the first example the desired positions might be 6 and 8 or 7 and 8. Positions 6and 7 contain letters 'a', position 8 contains letter 'b'. The pair of positions 1and 8 is not suitable because there is an uppercase letter 'B' between these position.

In the second example desired positions can be 7, 8 and 11. There are other ways to choose pretty set consisting of three elements.

In the third example the given string s does not contain any lowercase letters, so the answer is 0.

题目大意:

就是说给一个字符串问你有多少 在不被大写字母分割的子串中(也就是不含大写字母的子串中),小写字母的种类数最多  有多少个。

解题报告:

反正数据量很小,,随便写就行。

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define ll long long
#define pb push_back
#define pm make_pair
#define fi first
#define se second
using namespace std;
const int MAX = 2e5 + 5;
int bk[MAX];
int cnt[505];
int n,tmp;
char s[505];
int main()
{cin>>n;cin>>s+1;int len = strlen(s+1),ans = 0,tmp=0;for(int i = 1; i<=len; i++) {if(isupper(s[i])) {memset(cnt,0,sizeof cnt);ans = max(ans,tmp);tmp=0;continue;}if(cnt[s[i]] == 0) {tmp++;cnt[s[i]]++;}}printf("%d\n",max(tmp,ans));return 0 ;}

总结:

注意最后输出的时候也需要取max,因为万一没进那个if(cnt[s[i]] == 0)这个if的话,,比如输入:x    那就凉凉啊。所以小地方一定要注意,,,还有一种处理办法就是每个tmp++之后就ans更新一下。。。还是那句话 一定要小范围测试一下!!

【 CodeForces - 864B】Polycarp and Letters(水题,字符串,有坑)相关推荐

  1. Codeforces 864 A Fair Game 水题

    题目链接: http://codeforces.com/problemset/problem/864/A 题目描述: 看不是是不是一串数中只有两种数且这两种数字的数量是相同的 解题思路: 水题, 水过 ...

  2. CodeForces - 1141D Colored Boots(暴力+水题)

    题目链接:点击查看 题目大意:给出两个字符串s和t,两个字符串中相同的字母可以匹配,问号可以和任意字符匹配,现在问两个字符串最多能匹配多少个字符,并给出匹配的下标 题目分析:挺好玩的一道水题,大体思路 ...

  3. 【CodeForces - 569B】Inventory (水题)

    题干: Companies always have a lot of equipment, furniture and other things. All of them should be trac ...

  4. codeforces 702A A. Maximum Increase(水题)

    题目链接: A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input sta ...

  5. Codeforces gym 100685 C. Cinderella 水题

    C. Cinderella Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/ ...

  6. codeforces 667A A. Pouring Rain(水题)

    题目链接: A. Pouring Rain time limit per test 1 second memory limit per test 256 megabytes input standar ...

  7. 【CodeForces - 485A】Factory (水题,抽屉原理,tricks)

    题干: One industrial factory is reforming working plan. The director suggested to set a mythical detai ...

  8. CodeForces - 25A IQ test【水题】

    题目链接:https://codeforces.com/contest/25/problem/A #include <iostream> using namespace std; int ...

  9. CodeForces - 29A Spit Problem【水题】

    题目链接:https://codeforces.com/contest/29/problem/A #include <iostream> #include <cstdio> # ...

  10. CodeForces - 29B Traffic Lights【水题】

    题目链接:https://codeforces.com/contest/29/problem/B #include <iostream> #include <cstdio> # ...

最新文章

  1. GitHub标星2000+,如何用30天啃完TensorFlow2.0?
  2. 如何扫描和修复 Linux 磁盘错误
  3. Win7下基于消息安全模式的WCF托管(IIS与WinForm)
  4. mysql timeout知多少
  5. ejabberd登陆不成功的解决方案
  6. enterprise architect复制到word中的标签怎么改变_7个 Word 技巧,不会别说自己会 Word...
  7. 从运维角度浅谈MySQL数据库优化
  8. wordpress插件-really-simple-ssl插件解决网站开启ssl证书后,图片不能正常显示
  9. 动态规划——打家劫舍||(Leetcode 213)
  10. 招聘贴---这个很重要嘛
  11. 普中科技51单片机——keil的介绍和PZ-ISP无法烧录问题
  12. JDBC和MySQL的实现原理
  13. Tess4J OCR简单使用教程
  14. 游戏及相关CG行业知识分享大V全整合
  15. 苹果home兼容问题修改--苹果fixed定位被遮挡-或者距离太近
  16. PHP strtoupper函数解析
  17. 7-76 查询水果价格
  18. 集群学习分享2:pcs+postgresql一主两从集群搭建
  19. iQQ 学习笔记1 :登录、验证码、收消息
  20. 云计算-Linux-云计算是啥.什么是Linux-小白

热门文章

  1. Parallel Extensions CTP第二版发布
  2. 2004-4-3+ asp.net编程环境的配置
  3. [Leedcode][JAVA][第820题][字典树][Set]
  4. PAT1130. Infix Expression (25) 中序遍历
  5. excel亮灯怎么设置_Excel表格技巧—怎么给表格设置密码
  6. android 滚动尺画到控件中间,android 刻度尺控件实现
  7. controller调用controller的方法_SpringCloud(5):Feign整合Ribbon和Hystrix来进行远程调用与服务熔断...
  8. css3 背景等比例,纯 CSS,不用背景,实现图片等比例展示
  9. linux修改grub权限,linux下肿么修改grub.cfg
  10. Linux 编译 libc log,在Android的源码中添加LOG