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. 在linux中安装VM tools

    step 1:虚拟机选择安装 Vmware tools ,在DVD中将.tar.gz的文件包拖到桌面中: step 2:打开终端,切换到桌面,cd /home/whoami/桌面 cd /home/u ...

  2. 你不知道的JavaScript LHS 和 RHS 查找

    今天在学习JavaScript的相关知识时接触到了 LHS(Left Hand Side)和 RHS(Right Hand Side)两种对变量查找的方法,之所以JavaScript要查找变量,那就先 ...

  3. python_面向对象——对象之间的关联关系

    1.将类中的对象关联起来(简单的方法) class Person: def __init__(self,name,age,sex): self.name = name self.age = age s ...

  4. node.js接收异步任务结果的两种方法----callback和事件广播

    事件广播 发送方调用emit方法,接收方调用on方法,无论发送方或是接收方,都会工作在一个频道 声明了一个模块,用于读取mime.json中的记录 var fs = require('fs'); va ...

  5. struts2之使用oracle分页(10)

    ToolsUtil //每页显示的记录数 public static final int NUM_PER_PAGE=5; /* * java.util.Date转java.sql.Date */ pu ...

  6. WeakReference 弱引用

    弱引用是使用WeakReference类创建的.因为对象可能在任意时刻被回收,所以在引用该对象前必须确认它存在. class MainEntryPoint { static void Main() { ...

  7. BZOJ 1299: [LLH邀请赛]巧克力棒 【SG函数/博弈分析/高斯消元】

    因为太懒,放个博客 我只写了O(2n)O(2^n)O(2n)的 CODE #include <cstdio> int n, x[15]; int main () { for(int T = ...

  8. Entity Framework学习过程

    ///安装ef nuget中文控制台指令 PM> Install-Package EntityFramework.zh-Hans <!--配置数据库连接--> <connect ...

  9. How to change the default browser in Visual Studio

    http://www.hanselman.com/blog/HowToChangeTheDefaultBrowserInVisualStudioProgrammaticallyWithPowerShe ...

  10. win10 开启全局代理

    1. 打开设置 2. 点击“网络和Internet” 3.设置手动代理 . 设置完成后就可以愉快的玩耍啦