Problema
A password is strong if it has at least 8 characters, at least one uppercase letter, at least one lowercase letter and at least one digit (English letters and 0–9).
Implement is_strong_password(password).
Input
password: The password to check (ASCII characters).
Output
Return true if all rules hold, otherwise false.
Vincoli
0 ≤ length of password ≤ 100
Esempi
Input:
password = "Secret123"
Output atteso:
expected = True
Input:
std::string password = "Secret123";
Output atteso:
bool expected = true;
Input:
string password = "Secret123";
Output atteso:
bool expected = true;
Spiegazione
9 characters with uppercase S, lowercase letters and digits: strong.
Input:
password = "password1"
Output atteso:
expected = False
Input:
std::string password = "password1";
Output atteso:
bool expected = false;
Input:
string password = "password1";
Output atteso:
bool expected = false;
Spiegazione
There is no uppercase letter, so it is not strong.
Come affrontarlo
Prova prima da solo, poi apri un suggerimento alla volta.
Suggerimento 1
La password deve soddisfare più condizioni indipendenti contemporaneamente.
Suggerimento 2
Tieni traccia se hai visto una lettera maiuscola, una minuscola e una cifra mentre controlli la lunghezza.
Suggerimento 3
Una stringa vuota o corta fallisce subito anche se contiene caratteri misti.
Complessità attesa
tempo O(n), spazio aggiuntivo O(1)
Riferimenti
Questa sfida è adattata per CodeUtility. Segui la traccia e i vincoli sopra.