Strong Password Checker II - Problem
Strong Password Checker II is a classic string validation problem that tests your ability to implement multiple criteria checking efficiently.
You're given a
Goal: Return
This problem is commonly used in cybersecurity applications and user registration systems to enforce password policies.
You're given a
password string and need to determine if it meets all of the following security requirements:- ✅ Length: At least 8 characters
- ✅ Lowercase: Contains at least one lowercase letter (a-z)
- ✅ Uppercase: Contains at least one uppercase letter (A-Z)
- ✅ Digit: Contains at least one digit (0-9)
- ✅ Special Character: Contains at least one special character from
"!@#$%^&*()-+" - ✅ No Adjacent Duplicates: No two identical characters appear consecutively
Goal: Return
true if the password is strong (meets ALL criteria), otherwise return false.This problem is commonly used in cybersecurity applications and user registration systems to enforce password policies.
Input & Output
example_1.py — Strong Password
$
Input:
password = "IloveLe3tcode!"
›
Output:
true
💡 Note:
The password meets all requirements: length >= 8 (14 chars), has lowercase letters (o,v,e,t,c,o,d,e), uppercase letters (I,L), digits (3), special character (!), and no adjacent duplicates.
example_2.py — Adjacent Duplicates
$
Input:
password = "Me+You--IsMyDream"
›
Output:
false
💡 Note:
Although the password has 17 characters and contains lowercase, uppercase, and special characters, it has adjacent duplicate characters '--' which violates the rule.
example_3.py — Missing Requirements
$
Input:
password = "1aB!"
›
Output:
false
💡 Note:
The password fails the length requirement (only 4 characters, needs at least 8). Even though it has all character types and no adjacent duplicates, it's too short.
Constraints
- 1 ≤ password.length ≤ 100
-
password consists of letters, digits, and special characters:
"!@#$%^&*()-+" - Password must satisfy all criteria to be considered strong
Visualization
Tap to expand
Understanding the Visualization
1
Length Scanner
First gate checks if ID badge has minimum 8 characters
2
Character Analysis
Advanced scanner analyzes each character for type classification
3
Requirement Tracking
Security system tracks which requirements have been satisfied
4
Final Verification
All checkpoints must be cleared for access approval
Key Takeaway
🎯 Key Insight: Single-pass validation efficiently checks all requirements simultaneously, making it the optimal O(n) solution for password strength verification.
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code