当前位置:网站首页>520.检测大写字母
520.检测大写字母
2022-04-23 04:15:00 【张.Joshua】
520.检测大写字母
- 题号:力扣520
- 知识点:字符串
- 目标完成度:20/150
- 总结
题干:

思路:
- 1.先判断第一个字母的大小写,如果第一个字母是小写,那么后面的必然都是小写,如果后面出现大写直接返回
False - 2.如果第一个字母的大写,再看第二个字母的大小写,如果第二个字母是小写,则后面的必然都是小写,如果后面出现大写直接返回
False - 3.如果第二个字母是大写,则后面的必然全都是大写,如果后面出现小写直接返回
False
#
# @lc app=leetcode.cn id=520 lang=python3
#
# [520] 检测大写字母
#
# @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
版权声明
本文为[张.Joshua]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_44742084/article/details/124325384
边栏推荐
- 【测绘程序设计】坐标反算神器V1.0(附C/C#/VB源程序)
- How Zotero quotes in word jump to references / hyperlink
- 【NeurIPS 2019】Self-Supervised Deep Learning on Point Clouds by Reconstructing Space
- 【论文阅读】【3d目标检测】Voxel Transformer for 3D Object Detection
- 【时序】基于 TCN 的用于序列建模的通用卷积和循环网络的经验评估
- The difference between lists, tuples, dictionaries and collections
- UDP协议与TCP协议
- 什么是软件验收测试,第三方软件检测机构进行验收测试有什么好处?
- Mysql出现2013 Lost connection to MySQL server during query
- Express middleware ② (classification of Middleware)
猜你喜欢
![[AI vision · quick review of robot papers today, issue 30] Thu, 14 APR 2022](/img/93/55ee30b99c7683edc612a09e30dfed.png)
[AI vision · quick review of robot papers today, issue 30] Thu, 14 APR 2022

MYSQL50道基础练习题

LabVIEW 小端序和大端序区别

洛谷P1858 【多人背包】 (背包求前k优解)

Network principle | connection management mechanism in TCP / IP important protocol and core mechanism

Xshell、Xftp连接新创建的Unbutu系统虚拟机全流程

C语言:恶搞小游戏

Does China Mobile earn 285 million a day? In fact, 5g is difficult to bring more profits, so where is the money?

Express中间件②(中间件的分类)

AI CC 2019 installation tutorial under win10 (super detailed - small white version)
随机推荐
[AI vision · quick review of today's sound acoustic papers, issue 2] Fri, 15 APR 2022
Chlamydia infection -- causes, symptoms, treatment and Prevention
Express中间件②(中间件的分类)
[AI vision · quick review of today's sound acoustic papers, issue 3] wed, 20 APR 2022
[latex] differences in the way scores are written
[AI vision · quick review of robot papers today, issue 29] Mon, 14 Feb 2022
MySQL 2013 lost connection to MySQL server during query
Understand the gut organ axis, good gut and good health
中国移动日赚2.85亿很高?其实是5G难带来更多利润,那么钱去哪里了?
[echart] démarrer avec echart
【BIM+GIS】ArcGIS Pro2.8如何打开Revit模型,BIM和GIS融合?
matlab讀取多張fig圖然後合並為一張圖(子圖的形式)
What is software acceptance testing? What are the benefits of acceptance testing conducted by third-party software testing institutions?
Difference between LabVIEW small end sequence and large end sequence
【论文阅读】【3d目标检测】Improving 3D Object Detection with Channel-wise Transformer
OpenCV----YOLACT实例分割模型推理
智能电子秤全国产化电子元件推荐方案
VSCode配置之Matlab极简配置
2021-09-03 crawler template (only static pages are supported)
减治思想——二分查找详细总结