当前位置:网站首页>6095. 强密码检验器 II
6095. 强密码检验器 II
2022-07-02 12:10:00 【紫菜(Nori)】
循环遍历每个字符判断,对于特殊字符,直接使用一个字符串去存储,利用find方法判断是否存在
class Solution {
public:
bool strongPasswordCheckerII(string password) {
if(password.size() < 8){
return false;
}
// 方便后面判断特殊字符是否存在
string specialStr = "[email protected]#$%^&*()-+";
char prevC = '/', nextC;
// 大写、小写字母、数字、特殊字符
bool lower = false, upper = false, number = false, special = false;
for(int i = 0; i < password.size(); i++){
nextC = password[i];
if(prevC == nextC){
// 连续出现相同字符则直接返回
return false;
}else if('a' <= nextC && 'z' >= nextC){
lower = true;
}else if('A' <= nextC && 'Z' >= nextC){
upper = true;
}else if('0' <= nextC && '9' >= nextC){
number = true;
}else if(!special){
// 记录特殊字符
int ind = specialStr.find(nextC);
// 如果找到则ind为对应位置的下标
if(ind >= 0 && ind < specialStr.size()){
special = true;
}
}
// 记录当前字符
prevC = nextC;
}
return (lower & upper & number & special);
}
};
边栏推荐
- folium,确诊和密接轨迹上图
- 03.golang初步使用
- There are 7 seats with great variety, Wuling Jiachen has outstanding product power, large humanized space, and the key price is really fragrant
- Let your HMI have more advantages. Fet-g2ld-c core board is a good choice
- Beijing rental data analysis
- 密码学基础知识
- 损失函数与正负样本分配:YOLO系列
- 高考分数线爬取
- 02.面向容器化后,必须面对golang
- 11_Redis_Hyperloglog_命令
猜你喜欢
【LeetCode】1162-地图分析
损失函数与正负样本分配:YOLO系列
. Net again! Happy 20th birthday
17_Redis_Redis发布订阅
4. Jctree related knowledge learning
15_Redis_Redis.conf详解
XML Configuration File
LeetCode刷题——统计各位数字都不同的数字个数#357#Medium
Evaluation of embedded rz/g2l processor core board and development board of Feiling
Semantic segmentation learning notes (1)
随机推荐
Redux - detailed explanation
Be a good gatekeeper on the road of anti epidemic -- infrared thermal imaging temperature detection system based on rk3568
LeetCode刷题——递增的三元子序列#334#Medium
2022 年辽宁省大学生数学建模A、B、C题(相关论文及模型程序代码网盘下载)
The traversal methods of binary tree mainly include: first order traversal, middle order traversal, second order traversal, and hierarchical traversal. First order, middle order, and second order actu
03_線性錶_鏈錶
03.golang初步使用
Bing.com网站
19_ Redis_ Manually configure the host after downtime
Data analysis thinking analysis methods and business knowledge - business indicators
There are 7 seats with great variety, Wuling Jiachen has outstanding product power, large humanized space, and the key price is really fragrant
15_Redis_Redis.conf详解
【LeetCode】1905-统计子岛屿
工程师评测 | RK3568开发板上手测试
13_ Redis_ affair
Semantic segmentation learning notes (1)
12_ Redis_ Bitmap_ command
02.面向容器化后,必须面对golang
【Leetcode】167-两数之和II -输入有序数组
Wechat Alipay account system and payment interface business process