520. Detect Capital
来源:互联网 发布:推广软件返现金 编辑:程序博客网 时间:2024/06/07 21:50
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.
这道题用正则表达式很清晰,正则式为“([A-Z]+)|([A-Z][a-z]*)|([a-z]+)”。代码如下:public class Solution { public boolean detectCapitalUse(String word) { String reg = "([A-Z]+)|([A-Z][a-z]*)|([a-z]+)"; return word.matches(reg); }}
0 0
- 【Leetcode】520. Detect Capital
- 520. Detect Capital (E)
- LeetCode 520. Detect Capital
- LeetCode 520. Detect Capital
- 520. Detect Capital
- LeetCode-520. Detect Capital
- 520. Detect Capital
- leetcode 520. Detect Capital
- 520. Detect Capital
- 520. Detect Capital
- 520. Detect Capital
- 520. Detect Capital
- leetcode 520. Detect Capital
- [leetcode] 520. Detect Capital
- 520. Detect Capital Easy
- 520. Detect Capital
- [LeetCode]520. Detect Capital
- 520. Detect Capital
- 运行Python程序的5种方式--Python(4)
- 基于proteus的51单片机仿真实例十九、用单片机端口演示数据的乘法运算结果
- 基于proteus的51单片机仿真实例二十、用单片机端口演示数据的除法运算结果
- Maven项目的pom.xml依赖下载失败或是取消之后如何重新更新
- Coursera ML笔记 -----week9-2 推荐系统
- 520. Detect Capital
- MySQL 性能优化方案
- 2017软院金山WPS补题 L
- [学习]Linux (sys)Log
- 纪录知识库-redis
- 关于软件架构的重要性
- log4j源码分析
- Hibernate 使用Intellij IDEA自动生成.hbm.xml文件
- php 中操作字符串的一些常用函数