public class Solution {
public bool DetectCapitalUse(string word) {
var length = word.Length; if (length > )
{
int UpCaseCount = ;
int LowCaseCount = ;
bool firstCapital = false;
bool firstTime = true;
foreach (var c in word)
{
if (char.IsUpper(c))
{
UpCaseCount++; if (firstTime)
{
firstCapital = true;
}
}
else if (char.IsLower(c))
{
LowCaseCount++;
}
firstTime = false;
} if (UpCaseCount == && firstCapital)
{
return true;
}
if (UpCaseCount == && LowCaseCount == length)
{
return true;
}
if (LowCaseCount == && UpCaseCount == length)
{
return true;
} return false;
}
else
{
return true;
}
}
}

https://leetcode.com/problems/detect-capital/#/description

leetcode520的更多相关文章

  1. [Swift]LeetCode520. 检测大写字母 | Detect Capital

    Given a word, you need to judge whether the usage of capitals in it is right or not. We define the u ...

随机推荐

  1. Hash表的平均查找长度ASL计算方法

    Hash表的“查找成功的ASL”和“查找不成功的ASL” ASL指的是 平均查找时间 关键字序列:(7.8.30.11.18.9.14) 散列函数: H(Key) = (key x 3) MOD 7 ...

  2. day13 python学习 迭代器,生成器

    1.可迭代:当我们打印 print(dir([1,2]))   在出现的结果中可以看到包含 '__iter__', 这个方法,#次协议叫做可迭代协议 包含'__iter__'方法的函数就是可迭代函数 ...

  3. git server side hook 试用

    git 的hook 是一个很方便的功能,我们可以使用hook 做好多处理,比如client side hook 进行 提交格式校验,server side 进行ci/cd 处理 测试使用docker- ...

  4. C语言面试题4

    第二部分:程序代码评价或者找错 1.下面的代码输出是什么,为什么?void foo(void){    unsigned int a = 6;    int b = -20;    (a+b > ...

  5. 淘宝 code 使用

    淘宝 code上 svn 使用,基本流程: 新建项目 mkdir 创建 branches 文件夹(新建项目的时候,只有 trunk) copy 来创建新分支 checkout 主干和(或)分支到本地 ...

  6. 一个经典的PHP加密解密算法

    项目中有时我们需要使用PHP将特定的信息进行加密,也就是通过加密算法生成一个加密字符串,这个加密后的字符串可以通过解密算法进行解密,便于程序对解密后的信息进行处理.最常见的应用在用户登录以及一些API ...

  7. Win7 搭建pptpvpn服务器方法

    打开网络与共享中心 选择更改适配器设置 选择菜单文件选项(若无菜单栏,可以按一下alt键就会显示出来的) 选择新建传入链接 选择需要哪些用户可以访问vpn服务器,把勾搭上,点击下一步 注意此处的通过i ...

  8. TroubleShoot: Fail to deploy Windows UAP to device: 0x80073CFD

    After creating "Blank App(Windows Universal)" targeting Windows Phone 10 in Visual Studio ...

  9. PHP按最大宽高等比例缩放图片类 http://www.oschina.net/code/snippet_876708_21113

    PHP按最大宽高等比例缩放图片类 http://www.oschina.net/code/snippet_876708_21113 php 等比例缩小图片 http://www.111cn.net/p ...

  10. 动态修改css 规则

    页面引用了两个样式表: <link href="css/mui.min.css" rel="stylesheet" /> <link href ...