problem

520. Detect Capital

题意:

题目中给出的三种情况,分别是全是大写、全是小写、首字母大写,这三种情况返回True;否则返回False;

solution:

class Solution {
public:
bool detectCapitalUse(string word) {
bool flag = false;
int cnt = ;
for(int i=; i<word.size(); i++)
{
char ch = word[i];
if(ch>='A'&&ch<='Z') cnt++;
}
if(cnt==word.size() || (cnt==&& word[]>='A'&&word[]<='Z') || cnt==) //err
{
flag = true;
}
return flag;
}
};

参考

1. Leetcode_520. Detect Capital;

【leetcode】520. Detect Capital的更多相关文章

  1. 【LeetCode】520. Detect Capital 解题报告(Java & Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 循环判断三个条件 大写字母个数和位置判断 根据首字符 ...

  2. 520. Detect Capital【easy】

    520. Detect Capital[easy] Given a word, you need to judge whether the usage of capitals in it is rig ...

  3. 50. leetcode 520. Detect Capital

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

  4. Leetcode 520. Detect Capital 发现大写词 (字符串)

    Leetcode 520. Detect Capital 发现大写词 (字符串) 题目描述 已知一个单词,你需要给出它是否为"大写词" 我们定义的"大写词"有下 ...

  5. 【LeetCode】Minimum Depth of Binary Tree 二叉树的最小深度 java

    [LeetCode]Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum dept ...

  6. 【Leetcode】Pascal&#39;s Triangle II

    Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3 ...

  7. 53. Maximum Subarray【leetcode】

    53. Maximum Subarray[leetcode] Find the contiguous subarray within an array (containing at least one ...

  8. 27. Remove Element【leetcode】

    27. Remove Element[leetcode] Given an array and a value, remove all instances of that value in place ...

  9. 【刷题】【LeetCode】007-整数反转-easy

    [刷题][LeetCode]总 用动画的形式呈现解LeetCode题目的思路 参考链接-空 007-整数反转 方法: 弹出和推入数字 & 溢出前进行检查 思路: 我们可以一次构建反转整数的一位 ...

随机推荐

  1. Wireless Network(并查集)

    POJ - 2236 #include<iostream> #include<algorithm> #include<cstring> #include<cm ...

  2. 2018/7/31-zznu-oj-问题 B: N! 普拉斯 -【求大数的阶乘-ll存不下-然后取尾零的个数输出-暴力模拟】

    问题 B: N! 普拉斯 时间限制: 1 Sec  内存限制: 128 MB提交: 114  解决: 35[提交] [状态] [讨论版] [命题人:admin] 题目描述 在处理阶乘时也需要借助计算器 ...

  3. MongoDB同步机制

    复制 在此页 冗余和数据可用性 在MongoDB中复制 异步复制 自动故障转移 读取操作 交易次数 更改流 附加的功能 甲副本集 MongoDB中是一组mongod其保持相同的数据集的过程.副本集提供 ...

  4. Vue -- element-ui FileSaver.js 导出

    html <el-button type="danger" @click="exportRs">导出Excel报表</el-button> ...

  5. POJ-1661-Help Jimmy(DP, 递推)

    链接: https://vjudge.net/problem/POJ-1661 题意: "Help Jimmy" 是在下图所示的场景上完成的游戏. 场景中包括多个长度和高度各不相同 ...

  6. mongod破解版的安装

    navicat for mongodb 12,又叫做navicat 12 for mongodb,是针对mongodb软件而开发的一款管理软件,拥有高效图形用户界面,能够连接本地或远程的MongoDB ...

  7. 题解 [JOI 2019 Final] 独特的城市

    题面 解析 首先有一个结论, 对一个点\(x\)有贡献的城市 肯定在它到离它较远的直径的端点的链上. 假设离它较远的端点是\(S\), 如果有一个点\(u\)不在\(x\)到\(S\)的链上, 却对\ ...

  8. Codeforces Round #350 (Div. 2) A B C D1 D2 水题【D2 【二分+枚举】好题】

    A. Holidays 题意:一个星球 五天工作,两天休息.给你一个1e6的数字n,问你最少和最多休息几天.思路:我居然写成模拟题QAQ. #include<bits/stdc++.h> ...

  9. HTML元素常用属性整理

    a标签 <!-- 去除下划线 --> a{ text-decoration:none; //去掉默认下滑线 color:#333; //设置默认颜色 } a:hover{ text-dec ...

  10. learning express step(九)

    router-level middleware works in the same way as application-level middleware, except it is bound to ...