leetcode 520 Detect Capital C++
来源:互联网 发布:溢价域名 编辑:程序博客网 时间:2024/05/29 01:56
这道题我用了从后往前的思路。
如果当前是小写的,上一个是大写的,直接false,否则continue
如果当前是大写的,上一个是大写的,continue,否则看当前是不是首尾,不是返回false。
6ms,打败70%+
bool detectCapitalUse(string word) { if (word.empty()) { return false; } bool isCapital = false; for (int i = word.size() - 1 ; i >= 0 ; --i) { if (word[i] <= 'z' && word[i] >= 'a') { if (isCapital) return false; } else { if (isCapital) continue; if (i != 0 && i != word.size() - 1) return false; isCapital = true; } } return true; }
阅读全文
0 0
- LeetCode 520:Detect Capital (c++)
- leetcode-520-Detect Capital
- Leetcode #520 Detect Capital
- [LeetCode]520 Detect Capital
- LeetCode 520:Detect Capital
- LeetCode 520 Detect Capital
- Leetcode 520 Detect Capital
- LeetCode 520 Detect Capital
- 【LeetCode】520 Detect Capital
- Leetcode 520 Detect Capital
- LeetCode.520 Detect Capital
- leetcode 520 Detect Capital C++
- leetcode 520[easy]---Detect Capital
- leetcode 520. Detect Capital(C语言)
- LeetCode 520 Detect Capital 检测大写
- 【Leetcode】520. Detect Capital
- LeetCode 520. Detect Capital
- LeetCode 520. Detect Capital
- JavaScript—字符串
- xutils3使用方法
- HDU 6138 Fleet of the Eternal Throne 后缀数组+字典树
- 2017ccpc网络赛CaoHaha's staff
- IE6中一些样式Bug及其解决方法
- leetcode 520 Detect Capital C++
- Hdu 6156 Palindrome Function
- 2048移动端适配
- Qt 5.9.1 参考手册 QtTest 第3章 模拟GUI事件
- Java八大排序算法之希尔排序
- 并查集:poj1611
- bzoj 2732 射箭 半平面交 解题报告
- C#调用C++库,如何捕获异常
- Python实现更相减损术求解最大公约数