520. 检测大写字母

520. 检测大写字母


题目链接:520. 检测大写字母

代码如下:

cpp 复制代码
class Solution 
{
public:
    bool detectCapitalUse(string word) 
    {
        int count=0;
        for(int i=0;i<word.size();i++)
        {
            if(word[i]>='A'&&word[i]<='Z')  {count++;}
        }
        if(count==0||count==word.size())    {return true;}
        if(count==1&&word[0]>='A'&&word[0]<='Z')  {return true;}
        return false;
    }
};
相关推荐
xlp666hub6 小时前
Leetcode第七题:用C++解决接雨水问题
c++·leetcode
肆忆_7 小时前
实战复盘:手写 C++ 虚拟机的高性能并行 GC (Thread Pool + Work Stealing)
c++
肆忆_7 小时前
虚函数进阶答疑:把上一篇博客评论区里最容易卡住的问题,一次追到底
c++
saltymilk1 天前
使用 C++ 模拟 ShaderLanguage 的 swizzle
c++·模板元编程
xlp666hub1 天前
Leetcode第五题:用C++解决盛最多水的容器问题
linux·c++·leetcode
得物技术1 天前
搜索 C++ 引擎回归能力建设:从自测到工程化准出|得物技术
c++·后端·测试
xlp666hub2 天前
Leetcode 第三题:用C++解决最长连续序列
c++·leetcode
会员源码网2 天前
构造函数抛出异常:C++对象部分初始化的陷阱与应对策略
c++
xlp666hub2 天前
Leetcode第二题:用 C++ 解决字母异位词分组
c++·leetcode
不想写代码的星星2 天前
static 关键字:从 C 到 C++,一篇文章彻底搞懂它的“七十二变”
c++