【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-整数反转 方法: 弹出和推入数字 & 溢出前进行检查 思路: 我们可以一次构建反转整数的一位 ...
随机推荐
- Java基础 使用转换流进行文件的复制 / RandomAccessFile 类进行文件的复制
笔记: **使用转换流进行文件的复制 文本文件---字节流FileInputStream--> [InputStreamReader] -----字符流BufferedReader------ ...
- 传说中Python最难理解的点,看这完篇就够了
本文转载自简书,作者为菜鸟,感谢作者的辛苦付出. 这不是我第一次学Python入门课,去年.前年我都学过Python入门.所以文章的标题一点都没有标题党的意思.但是整个入门篇还有一个最难的东西没有讲, ...
- JavaScript001,鼠标点击改变文字或图片
<h3>我的第一个Javascript</h3> <p id="demo1">1.点击按钮,改变内容!</p> <!-- 设置 ...
- c语言学习、工作相关必备的常用网站
1.https://zh.cppreference.com/,c.c++参考手册, 2.http://www.cplusplus.com/,在线查看c.c++函数的定义及用法 3.http://c-f ...
- 使用Eclipse进行远程调试(转)
做开发好多年了,Debug大家肯定都不陌生,绝对称得上是家常便饭了.博主虽不敢妄下断言,但是这里也猜一下,肯定有很多人都没有使用过Remote Debug(远程调试).说来惭愧,博主也是工作了3年才用 ...
- C#第一章 第一个C#程序
第一个C#程序 namespace 是C#中组织代码的方式,它的作用那个类似java中的包 using 在Java中作用如果导入其他包 应该是用import关键字而在C#中应使用using关键字来引用 ...
- [USACO19OPEN]Snakes
题目链接 题目简介:有n组,每组有若干个蛇的蛇队伍.(也可以理解为n条长度若干的蛇.)我们要用网捕捉,中途可以改变网的大小.目标是浪费空间最小. 解法:首先明确方法:DP.设f[i][t]为捕捉了n条 ...
- click([[data],fn]) 触发每一个匹配元素的click事件。
click([[data],fn]) 概述 触发每一个匹配元素的click事件. 这个函数会调用执行绑定到click事件的所有函数.大理石平台精度等级 参数 fnFunctionV1.0 在每一个匹配 ...
- PHP mmysqli_affected_rows(connection);函数
mysqli_affected_rows(); 函数返回前一次 MySQL 操作所影响的记录行数. mysqli_affected_rows(connection); connection 必需.规定 ...
- 009_STM32程序移植之_内部falsh
flash 模拟 EEPROM 实验 1. 测试环境:STM32C8T6 2. 测试接口: 3. 串口使用串口一,波特率9600 单片机引脚------------CH340引脚 VCC---- ...