【leetcode】520. Detect Capital
problem
题意:
题目中给出的三种情况,分别是全是大写、全是小写、首字母大写,这三种情况返回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的更多相关文章
- 【LeetCode】520. Detect Capital 解题报告(Java & Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 循环判断三个条件 大写字母个数和位置判断 根据首字符 ...
- 520. Detect Capital【easy】
520. Detect Capital[easy] Given a word, you need to judge whether the usage of capitals in it is rig ...
- 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 ...
- Leetcode 520. Detect Capital 发现大写词 (字符串)
Leetcode 520. Detect Capital 发现大写词 (字符串) 题目描述 已知一个单词,你需要给出它是否为"大写词" 我们定义的"大写词"有下 ...
- 【LeetCode】Minimum Depth of Binary Tree 二叉树的最小深度 java
[LeetCode]Minimum Depth of Binary Tree Given a binary tree, find its minimum depth. The minimum dept ...
- 【Leetcode】Pascal's Triangle II
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3 ...
- 53. Maximum Subarray【leetcode】
53. Maximum Subarray[leetcode] Find the contiguous subarray within an array (containing at least one ...
- 27. Remove Element【leetcode】
27. Remove Element[leetcode] Given an array and a value, remove all instances of that value in place ...
- 【刷题】【LeetCode】007-整数反转-easy
[刷题][LeetCode]总 用动画的形式呈现解LeetCode题目的思路 参考链接-空 007-整数反转 方法: 弹出和推入数字 & 溢出前进行检查 思路: 我们可以一次构建反转整数的一位 ...
随机推荐
- NLP传统基础(3)---潜在语义分析LSA主题模型---SVD得到降维矩阵
https://www.jianshu.com/p/9fe0a7004560 一.简单介绍 LSA和传统向量空间模型(vector space model)一样使用向量来表示词(terms)和文档(d ...
- Java字节码常量池深入剖析
继续来分析Java字节码,上一节分析了魔数的规则,接下来继续往下分析,其上次总结的规则也一起贴出来: 1.使用javap -verbose命令分析一个字节码文件时,将会分析该字节码文件的魔数.版本号. ...
- c#截图功能
简化版: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Sys ...
- 怎奈风云多变换,骚完一波还一波,记PHP mongodb驱动的2019年11月用法
怎么,觉得pecl下一个扩展包,phpize make make install php.ini里引用一下 mongodb.so就万事大吉了? Deeply Sorry!看到MongoDB\Driv ...
- python自动华 (七)
Python自动化 [第七篇]:Python基础-面向对象高级语法.异常处理.Scoket开发基础 本节内容: 1. 面向对象高级语法部分 1.1 静态方法.类方法.属性方法 1.2 ...
- X509
1 打开iis 找到部署的站点应用连接池,高级设置,“加载用户配置文件”项的值改为true 2 用户:certmgr.msc 本地计算机:mmc——文件——证书 --CN = QALINE001.on ...
- [USACO17JAN] 晋升者计数 dfs序+树状数组
[USACO17JAN] 晋升者计数 dfs序+树状数组 题面 洛谷P3605 题意:一棵有点权的树,找出树中所有\((u,v)\)的对数,其中\(u,v\)满足\(val(u)\le val(v)\ ...
- 顺序模型api
Compile:配置模型,然后进行训练 compile(optimizer, loss=None, metrics=None, loss_weights=None, sample_weight_mod ...
- Ubuntu 14.04 网卡网关配置修改
#添加网关route add default gw 192.168.5.1#强制修改网卡地址ifconfig eth0 192.168.5.40 netmask 255.255.255.0. 服务器需 ...
- masm 编译贪吃蛇游戏
code: ;TITLE GAME4TH PAGE , STSEG SEGMENT DB DUP () STSEG ENDS ;----------------------------------- ...