Password Strength Checker - Problem

Given a password string, check if it meets all the strength requirements.

Requirements:

  • Minimum 8 characters long
  • Contains at least one uppercase letter (A-Z)
  • Contains at least one lowercase letter (a-z)
  • Contains at least one digit (0-9)
  • Contains at least one special character (!@#$%^&*)

Return true if the password is strong, false otherwise.

Input & Output

Example 1 — Strong Password
$ Input: password = "Password123@"
Output: true
💡 Note: Length is 12 (≥8), contains uppercase 'P', lowercase letters 'assword', digits '123', and special character '@'. All requirements satisfied.
Example 2 — Too Short
$ Input: password = "Pass1@"
Output: false
💡 Note: Length is only 6 characters, which is less than the required minimum of 8 characters.
Example 3 — Missing Special Character
$ Input: password = "Password123"
Output: false
💡 Note: Has length ≥8, uppercase, lowercase, and digits, but missing a special character from the set !@#$%^&*.

Constraints

  • 1 ≤ password.length ≤ 100
  • Password contains only ASCII characters
  • Special characters are limited to: !@#$%^&*

Visualization

Tap to expand
INPUT PASSWORDVALIDATION PROCESSSTRENGTH RESULTPassword123@Length: 12 charactersContains mixed case, digits, symbols1Length ≥ 8: ✓ (12)2Uppercase: ✓ (P)3Lowercase: ✓ (assword)4Digits: ✓ (123)5Special: ✓ (@)All Requirements Met!trueStrong PasswordPasses all 5 security checksSecurity Level: HIGHSuitable for sensitive accountsKey Insight:Single pass validation with boolean flags is more efficient than multiple string scans.Track all requirements simultaneously while iterating through the password once.TutorialsPoint - Password Strength Checker | Single Pass Validation
Asked in
Microsoft 25 Amazon 18 Google 15
28.4K Views
Medium Frequency
~15 min Avg. Time
892 Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen