-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLeetcode2269.cpp
More file actions
42 lines (36 loc) · 977 Bytes
/
Leetcode2269.cpp
File metadata and controls
42 lines (36 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
[200~class Solution {
public:
bool strongPasswordCheckerII(string password) {
if(password.size()<8)return false;
unordered_map<char,int> hash;
char s,c,m,d;
bool special=false, cap=false, small=false, digit=false;
for(char x : password){
hash[x]++;
}
for(int i=0;i<password.size();i++)
{
if(i>0 && password[i]==password[i-1])return false;
if( password[i]>='A' && password[i]<='Z')
{
cap = true;
}
else if(password[i]>='a' && password[i]<='z')
{
small = true;
}
else if( password[i]>='0' && password[i]<='9')
{
digit = true;
}
else{
special = true;
}
}
if(special && cap && small && digit)
{
return true;
}
return false;
}
};