当前位置:网站首页>520. Detect capital letters
520. Detect capital letters
2022-04-23 04:32:00 【Zhang Joshua】
520. Detect capital letters
- Question no : Power button 520
- Knowledge point : character string
- Goal completion :20/150
- summary
stem :
Ideas :
- 1. First judge the case of the first letter , If the first letter is lowercase , Then the following must be lowercase , If it appears directly after
False
- 2. If the first letter is capitalized , Look at the case of the second letter , If the second letter is lowercase , Then the following must be lowercase , If it appears directly after
False
- 3. If the second letter is capitalized , Then the following must be all capitalized , If lowercase appears after it, it directly returns
False
#
# @lc app=leetcode.cn id=520 lang=python3
#
# [520] Detect capital letters
#
# @lc code=start
class Solution:
def detectCapitalUse(self, word: str) -> bool:
a = ord('a')
z = ord('z')
A = ord('A')
Z = ord('Z')
if len(word) <= 1:
return True
if a<=ord(word[0])<=z:
for i in range(len(word)):
if A<=ord(word[i])<=Z:
return False
return True
elif A<=ord(word[0])<=Z:
if a<=ord(word[1])<=z:
for j in range(1, len(word)):
if A<=ord(word[j])<=Z:
return False
return True
for l in range(1, len(word)):
if a<=ord(word[l])<=z:
return False
return True
# @lc code=end
版权声明
本文为[Zhang Joshua]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230415046514.html
边栏推荐
- 针对NFT的网络钓鱼
- The latest price trend chart and trading points of London Silver
- Kotlin. The binary version of its metadata is 1.6.0, expected version is 1.1.15.
- 【Pytorch基础】torch.split()用法
- 2020 is coming to an end, special and unforgettable.
- [echart] Introduction to echart
- Unipolar NRZ code, bipolar NRZ code, 2ASK, 2FSK, 2PSK, 2DPSK and MATLAB simulation
- 指纹Key全国产化电子元件推荐方案
- 【BIM入门实战】Revit建筑墙体:构造、包络、叠层图文详解
- 229. 求众数 II
猜你喜欢
随机推荐
mysql table 中增加列的SQL语句
VSCode配置之Matlab极简配置
Iron and intestinal flora
优麒麟 22.04 LTS 版本正式发布 | UKUI 3.1开启全新体验
The difference between lists, tuples, dictionaries and collections
顺序表的基本操作
减治思想——二分查找详细总结
Operating skills of spot gold_ Wave estimation curve
/etc/bash_completion.d目录作用(用户登录立刻执行该目录下脚本)
matlab讀取多張fig圖然後合並為一張圖(子圖的形式)
单片机串口数据处理(1)——串口中断发送数据
第四章 --- 了解标准设备文件、过滤器和管道
为什么推荐你学嵌入式
Detailed explanation of life cycle component of jetpack
補:注解(Annotation)
IEEE Transactions on Systems, Man, and Cybernetics: Systems(TSMC)投稿须知
洛谷P1858 【多人背包】 (背包求前k优解)
PHP export excel table
Unipolar NRZ code, bipolar NRZ code, 2ASK, 2FSK, 2PSK, 2DPSK and MATLAB simulation
Matlab reads multiple fig graphs and then combines them into one graph (in the form of sub graph)