+ 1

I don't know why it fail in test 7

#include <iostream> #include<map> using namespace std; char specialChars [7] = {'!', '@', '#', '

#x27;, '%', '&', '*'}; bool hasSpecialChar(string str){ map<char,int> mp; int cnt = 0; for(auto s : str){ mp[s]++; } for(int i = 0; i < 7; ++i){ if(mp.count(specialChars[i])){ cnt += mp[specialChars[i]]; } } return (cnt >= 2); } int main() { string pass; cin >> pass; if(hasSpecialChar(pass) && pass.size() >= 7){ cout << "Strong"; }else{ cout << "Weak"; } return 0; }

26th Feb 2022, 10:44 PM
AbdelRhman Abouelez
AbdelRhman Abouelez - avatar
2 Answers
+ 3
The password is valid if it has at least 2 numbers. https://code.sololearn.com/c9chgaQruw8s
26th Feb 2022, 11:10 PM
SoloProg
SoloProg - avatar
+ 2
SoloProg Thanks I fixed it
26th Feb 2022, 11:13 PM
AbdelRhman Abouelez
AbdelRhman Abouelez - avatar