欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1760B.Atilla's Favorite Problem
Atilla's Favorite Problem
In order to write a string, Atilla needs to first learn all letters that are contained in the string.
Atilla needs to write a message which can be represented as a string . He asks you what is the minimum alphabet size required so that one can write this message.
The alphabet of size () contains only the first Latin letters. For example an alphabet of size contains only the characters a, b, c and d.
Input
The first line contains a single integer () — the number of test cases.
The first line of each test case contains a single integer () — the length of the string.
The second line of each test case contains a string of length , consisting of lowercase Latin letters.
Output
For each test case, output a single integer — the minimum alphabet size required to so that Atilla can write his message .
Note
For the first test case, Atilla needs to know only the character a, so the alphabet of size which only contains a is enough.
For the second test case, Atilla needs to know the characters d, o, w, n. The smallest alphabet size that contains all of them is (such alphabet can be represented as the string abcdefghijklmnopqrstuvw).
Samples
5
1
a
4
down
10
codeforces
3
bcf
5
zzzzz
1
23
19
6
26
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |