LeetCode:520. Detect Capital
来源:互联网 发布:数据库支持的数据类型 编辑:程序博客网 时间:2024/05/16 13:03
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:
- All letters in this word are capitals, like "USA".
- All letters in this word are not capitals, like "leetcode".
- Only the first letter in this word is capital if it has more than one letter, like "Google".
Example 1:
Input: "USA"Output: True
Example 2:
Input: "FlaG"Output: False
Note: The input will be a non-empty word consisting of uppercase and lowercase latin letters.
AC:
class Solution(object): def detectCapitalUse(self, word): """ :type word: str :rtype: bool """ return word.isupper() or word.islower() or word.istitle()
阅读全文
0 0
- 【Leetcode】520. Detect Capital
- LeetCode 520. Detect Capital
- LeetCode 520. Detect Capital
- LeetCode-520. Detect Capital
- leetcode 520. Detect Capital
- leetcode 520. Detect Capital
- [leetcode] 520. Detect Capital
- [LeetCode]520. Detect Capital
- LeetCode | 520. Detect Capital
- 【LeetCode】520. Detect Capital
- LeetCode 520. Detect Capital
- leetcode 520. Detect Capital
- LeetCode 520. Detect Capital
- [leetcode]: 520. Detect Capital
- leetcode 520. Detect Capital
- LeetCode:520. Detect Capital
- 【Leetcode】520. Detect Capital
- LeetCode: 520. Detect Capital
- Java思维导图(4)--多线程
- StateAttribute类
- 【笔记】Android NotificationListenerService监听短信、来电、微信、QQ等通知消息
- 12、madplay的MP3播放器移植
- 积木城堡(Vijos-1059)
- LeetCode:520. Detect Capital
- 机器学习week1-3笔记:线性回归、逻辑回归
- 1066 Bash游戏
- iOS开发UI篇
- 验证码识别之模型训练
- 【R语言爬虫】网贷天眼平台表格数据爬虫1
- js 弹出对话框3种方式 .
- openjudge F:Delta Quadrant(坑)
- 2017国际大学生程序设计大赛全国邀请赛(陕西)小结