C语言 | Leetcode C语言题解之第520题检测大写字母

题目:

题解:

cpp 复制代码
bool detectCapitalUse(char * word){
    int len = strlen(word);
    int res = 0;
    int index = -1;
    if(len == 1)
        return true;
    else{
        for(int i = 0; i < len; i++){
            if(isupper(word[i])){
                res++;
                index = i;
            }
        }
    }
    return res == len || res == 0 || (res == 1 && index == 0);
}
相关推荐
TimberWill23 分钟前
哈希-02-最长连续序列
算法·leetcode·排序算法
Morwit40 分钟前
【力扣hot100】64. 最小路径和
c++·算法·leetcode
leoufung41 分钟前
LeetCode 373. Find K Pairs with Smallest Sums:从暴力到堆优化的完整思路与踩坑
java·算法·leetcode
wifi chicken1 小时前
数组遍历求值,行遍历和列遍历谁更快
c语言·数据结构·算法
南棱笑笑生3 小时前
20251224给飞凌OK3588-C开发板适配Rockchip原厂的Buildroot【linux-6.1】系统时确认ssh服务【内置dropbear】
linux·c语言·ssh·rockchip
晨晖25 小时前
顺序查找:c语言
c语言·开发语言·算法
LYFlied5 小时前
【每日算法】LeetCode 64. 最小路径和(多维动态规划)
数据结构·算法·leetcode·动态规划
sin_hielo6 小时前
leetcode 3074
数据结构·算法·leetcode
程序员-King.6 小时前
day124—二分查找—最小化数组中的最大值(LeetCode-2439)
算法·leetcode·二分查找
阿华hhh6 小时前
Linux系统编程(网络udp)
linux·服务器·c语言·网络·网络协议·udp