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. 93服务器上获取json数据

    jdf u -p上传html文件,上传到page域名下:jdf u 上传css和js 上传到misc域名下: json数据放在html下,因为ajax请求是按照html路径走的,所以json数据放在h ...

  2. git 知识点

    git 删除远程已经推送过的文件或者文件夹 git rm -r --cached [文件或文件夹] git status git add . git commit -m '删除远程仓库文件,本地仓库和 ...

  3. mysql 官方docker镜像使用教程

    首先是pull image,这里我拉取的是5.x版本最新版: docker pull mysql:5 拉下来以后大可以按照官方的说明无脑启动,但是外部无法访问,所以绑定端口:docker run -- ...

  4. POJ3013 Big Christmas Tree

    题目:http://poj.org/problem?id=3013 求每个点到1的最短路.不是最小生成树. 总是WA.看讨论里说INF至少2e10,于是真的A了! 算一下,dis最大可能3276800 ...

  5. 更新上篇文章 调用三级目录文章内容 dede频道页实现三级栏目嵌套调用文章

    原文:http://www.wuaie.com/?p=66 源码改写 $typeid = $row['id']; if((class_exists('PartView'))) { $pv = new ...

  6. Linux strace命令 一

    简介 strace常用来跟踪进程执行时的系统调用和所接收的信号. 在Linux世界,进程不能直接访问硬件设备,当进程需要访问硬件设备(比如读取磁盘文件,接收网络数据等等)时,必须由用户态模式切换至内核 ...

  7. PMP学习笔记

    PMI:Project Management Institute,项目管理协会于1969年在美国成立,致力于全球范围内的项目管理研究.标准制定和出版.价值倡导.职业认证和学位 课程认证.现在,PMI已 ...

  8. SpringMVC 获取请求参数

    1.获取Request response对象 在SpringMVC的注解开发中,可以选择性的接收Request和Response对象来使用 2.获取request对象请求参数 a.通过request对 ...

  9. 汇编,浮点运算符,fldpi,fmul等指令说明.

    协处理器指令系统 协处理器共有68条不同的指令,汇编程序在遇到协处理器指令助记符时,都会将其转换成机器语言的ESC指令,ESC指令代表了协处理器的操作码. 协处理器指令在执行过程中,需要访问内存单元时 ...

  10. GIS(地理信息系统)

    ylbtech-杂项:GIS(地理信息系统) 地理信息系统(Geographic Information System或 Geo-Information system,GIS)有时又称为“地学信息系统 ...