当前位置:网站首页>Leetcode simple problem strong password checker II
Leetcode simple problem strong password checker II
2022-07-21 06:21:00 【·Starry Sea】
subject
If a password meets all of the following conditions , We call it a strong password :
It has at least 8 Characters .
Include at least A lowercase English Letter .
Include at least A capital English Letter .
Include at least A number .
Include at least A special character . The special characters are :“[email protected]#$%^&*()-+” One of them .
it No contain 2 Consecutive identical characters ( For example “aab” Does not meet this condition , however “aba” Meet this condition ).
Give you a string password , If it is a strong password , return true, Otherwise return to false .
Example 1:
Input :password = “IloveLe3tcode!”
Output :true
explain : The password meets all requirements , So we go back to true .
Example 2:
Input :password = “Me+You–IsMyDream”
Output :false
explain : Password does not contain numbers , And contains 2 Consecutive identical characters . So we go back to false .
Example 3:
Input :password = “1aB!”
Output :false
explain : Password does not meet length requirements . So we go back to false .
Tips :
1 <= password.length <= 100
password Contain letters , Numbers and “[email protected]#$%^&*()-+” These special characters .
source : Power button (LeetCode)
Their thinking
The topic is relatively simple , Only record here .
class Solution:
def strongPasswordCheckerII(self, password: str) -> bool:
check_list=[False]*5+[True]
sp=set("[email protected]#$%^&*()-+")
n=len(password)
if n>7:
check_list[0]=True
else:
return False
for i in range(n):
if password[i].islower():
check_list[1]=True
if password[i].isupper():
check_list[2]=True
if password[i].isdigit():
check_list[3]=True
if password[i] in sp:
check_list[4]=True
if i>0 and password[i]==password[i-1]:
check_list[5]=False
return all(check_list)
边栏推荐
猜你喜欢
ASP.NET Core 6框架揭秘实例演示[01]: 编程初体验
安科瑞马达监控方案低压电动机回路及馈线配电回路电力能源监测
莫比乌斯反演-小总结
Redis-SortSet类型
R语言使用逻辑回归Logistic、单因素方差分析anova、异常点分析和可视化分类iris鸢尾花数据集
项目管理工具禅道
Ankerui motor monitoring scheme low voltage motor circuit and feeder distribution circuit power energy monitoring
“問天號”已就比特!喻京川2013年暢想的《中國空間站》,即將啟航星辰大海!...
第一章第十三节:循环语句:for循环
win10开机启动ps1脚本
随机推荐
GBase 8s如何句查询关系数据库以从复杂类型中选择数据的样本语 法和结果
利用神器Typora+PicGo,实现有道云不用会员就可在Markdown自动上传图片
掌握JedisPoolConfig参数配置,学会调优技能
边云协同场景下基于强化学习的精英分层任务卸载策略研究
没有了可用Task slot,Flink新增任务会怎样?
组件化与模块化
Ankerui motor monitoring scheme low voltage motor circuit and feeder distribution circuit power energy monitoring
提取excel表头
第一章 第六节:变量
Redis sortset type
一个诡异的 JedisConnectionException: Connection refused 问题
jenkins pipeline下载代码到指定workspace
A collection of open source scanners developed by security industry practitioners
Redis set type
Le point d'interrogation est en place! Yu Jingchuan 2013 Best think "China Space Station", stars of the Sea to navigate!...
基于主动学习和Wi-Fi感知的人体识别系统
第一章第十一节:循环语句while
第一章第九节:最简单的用户交互
Flink实战:消费Wikipedia实时消息
“問天號”已就比特!喻京川2013年暢想的《中國空間站》,即將啟航星辰大海!...