LeetCode520. Detect Capital--检测单词的大写字母是否符合规范

给定一个单词,需要判断其大写字母的使用是否正确。正确的情况包括:所有字母大写、所有字母小写或仅首字母大写。其他情况则视为不正确。示例和注意事项说明了具体判断标准。
摘要由CSDN通过智能技术生成

Given a word, you need to judge whether the usage of capitals in it is right or not.

We define the usage of capitals in a word to be right when one of the following cases holds:

  1. All letters in this word are capitals, like "USA".//所有单词都大写
  2. All letters in this word are not capitals, like "leetcode".//所有单词都小写
  3. Only the first letter in this word is capital, like "Google".//只有首字母大写,其余小写.

Otherwise, we define that this word doesn't use capitals in a right way.//否则,我们定义这个词没有正确地使用大写字母。

 

Example 1:

Input: "USA"
Output: True

 

Example 2:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

二十六画生的博客

你的鼓励是我创作最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值