当前位置:网站首页>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
边栏推荐
- 【测绘程序设计】坐标反算神器V1.0(附C/C#/VB源程序)
- Stm32f4 MCU ADC sampling and FFT of ARM-DSP Library
- Inverse system of RC low pass filter
- HMS Core Discovery第14期回顾长文|纵享丝滑剪辑,释放视频创作力
- 【BIM入门实战】Revit中的墙体层次以及常见问题解答
- RC低通滤波器的逆系统
- Introduction to Cortex-M3 register set, assembly language and C language interface
- 2020 is coming to an end, special and unforgettable.
- [BIM introduction practice] wall hierarchy and FAQ in Revit
- Effects of antibiotics on microbiome and human health
猜你喜欢
QtSpim手册-中文翻译
[AI vision · quick review of NLP natural language processing papers today, issue 31] Fri, 15 APR 2022
QT program integration easyplayer RTSP streaming media player screen flicker what is the reason?
[AI vision · quick review of robot papers today, issue 31] Fri, 15 APR 2022
Interaction of diet gut microbiota on cardiovascular disease
阿里十年技术专家联合打造“最新”Jetpack Compose项目实战演练(附Demo)
Chlamydia infection -- causes, symptoms, treatment and Prevention
Inverse system of RC low pass filter
小红书被曝整体裁员20%,大厂之间内卷也很严重
STM32F4单片机ADC采样及ARM-DSP库的FFT
随机推荐
2020 is coming to an end, special and unforgettable.
KVM error: Failed to connect socket to ‘/var/run/libvirt/libvirt-sock‘
HMS Core Discovery第14期回顾长文|纵享丝滑剪辑,释放视频创作力
【论文阅读】【3d目标检测】Improving 3D Object Detection with Channel-wise Transformer
Express middleware ② (classification of Middleware)
Opencv -- yoact case segmentation model reasoning
QtSpim手册-中文翻译
阿里十年技术专家联合打造“最新”Jetpack Compose项目实战演练(附Demo)
IDE Idea 自动编译 与 On Upate Action 、 On Frame Deactivation 的配置
[AI vision · quick review of robot papers today, issue 31] Fri, 15 APR 2022
Express中间件①(中间件的使用)
STM32单片机ADC规则组多通道转换-DMA模式
递归调用--排列的穷举
Understand the gut organ axis, good gut and good health
[AI vision · quick review of robot papers today, issue 32] wed, 20 APR 2022
Leetcode->1 两数之和
补充番外14:cmake实践项目笔记(未完待续4/22)
Chapter 4 - understanding standard equipment documents, filters and pipelines
Basic use of shell WC (counting the number of characters)
国外LEAD,联盟经理常见问答