forked from imabhinav-am/Competetive-Programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStrong Password.cpp
More file actions
49 lines (45 loc) · 990 Bytes
/
Copy pathStrong Password.cpp
File metadata and controls
49 lines (45 loc) · 990 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
43
44
45
46
47
48
#include <bits/stdc++.h>
using namespace std;
int minimumNumber(int n, string pass) {
int ctr=0,flagU=0,flagN=0,flagL=0,flagS=0;
for(int i=0; i<n; i++){
if(int(pass[i])>=65 && int(pass[i])<=90 && flagU == 0){
ctr++;
flagU = 1;
}
if(int(pass[i])>=97 && int(pass[i])<=122 && flagL == 0){
ctr++;
flagL = 1;
}
if(int(pass[i])>=48 && int(pass[i])<=57 && flagN == 0){
ctr++;
flagN = 1;
}
if((pass[i]=='!' || pass[i]=='@'||pass[i]=='#'||pass[i]=='$'||pass[i]=='%'||pass[i]=='^'
||pass[i]=='&'||pass[i]=='*'||pass[i]=='('||pass[i]==')'||pass[i]=='-'||pass[i]=='+') && flagS == 0){
ctr++;
flagS = 1;
}
if(ctr == 4){
break;
}
}
if(n < 6){
if((6-n) > 4 - ctr){
return (6 - n);
}
else
return (4 - ctr);
}
else
return (4-ctr);
}
int main() {
int n;
cin >> n;
string password;
cin >> password;
int answer = minimumNumber(n, password);
cout << answer << endl;
return 0;
}