当前位置:网站首页>6095. Strong password checker II
6095. Strong password checker II
2022-07-02 15:40:00 【Laver (nori)】
Loop through each character to judge , For special characters , Directly use a string to store , utilize find Method to judge whether there is
class Solution {
public:
bool strongPasswordCheckerII(string password) {
if(password.size() < 8){
return false;
}
// It is convenient to judge whether special characters exist later
string specialStr = "[email protected]#$%^&*()-+";
char prevC = '/', nextC;
// Capitalization 、 Lowercase letters 、 Numbers 、 Special characters
bool lower = false, upper = false, number = false, special = false;
for(int i = 0; i < password.size(); i++){
nextC = password[i];
if(prevC == nextC){
// If the same character appears continuously, it will return directly
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){
// Record special characters
int ind = specialStr.find(nextC);
// If found, then ind Is the subscript of the corresponding position
if(ind >= 0 && ind < specialStr.size()){
special = true;
}
}
// Record current character
prevC = nextC;
}
return (lower & upper & number & special);
}
};
边栏推荐
- Solve the problem of frequent interruption of mobaxterm remote connection
- 士官类学校名录
- 14_ Redis_ Optimistic lock
- Case introduction and problem analysis of microservice
- Pytoch saves tensor to Mat file
- 损失函数与正负样本分配:YOLO系列
- 17_ Redis_ Redis publish subscription
- 18_ Redis_ Redis master-slave replication & cluster building
- LeetCode_ Sliding window_ Medium_ 395. Longest substring with at least k repeated characters
- JVM architecture, classloader, parental delegation mechanism
猜你喜欢
MySQL calculate n-day retention rate
密码学基础知识
YOLOV5 代码复现以及搭载服务器运行
18_ Redis_ Redis master-slave replication & cluster building
面对“缺芯”挑战,飞凌如何为客户产能提供稳定强大的保障?
微信支付宝账户体系和支付接口业务流程
Engineer evaluation | rk3568 development board hands-on test
Yolov5 code reproduction and server operation
Be a good gatekeeper on the road of anti epidemic -- infrared thermal imaging temperature detection system based on rk3568
[network security] network asset collection
随机推荐
Loss function and positive and negative sample allocation: Yolo series
(Video + graphic) machine learning introduction series - Chapter 5 machine learning practice
Bing. Com website
How to avoid 7 common problems in mobile and network availability testing
How to choose a third-party software testing organization for automated acceptance testing of mobile applications
How does the computer set up speakers to play microphone sound
夏季高考文化成绩一分一段表
MySQL calculate n-day retention rate
Bing.com网站
QML pop-up frame, customizable
College entrance examination score line climbing
[leetcode] 283 move zero
16_ Redis_ Redis persistence
Evaluation of embedded rz/g2l processor core board and development board of Feiling
2022 年辽宁省大学生数学建模A、B、C题(相关论文及模型程序代码网盘下载)
I made an istio workshop. This is the first introduction
Download blender on Alibaba cloud image station
面对“缺芯”挑战,飞凌如何为客户产能提供稳定强大的保障?
Party History Documentary theme public welfare digital cultural and creative products officially launched
6092. 替换数组中的元素