Password Validation - aloalgo

Password Validation

Easy

You are given a string password.

Your task is to determine whether the password is valid according to the following rules:

  • It contains at least 8 characters.
  • It contains at least one uppercase letter (A-Z).
  • It contains at least one lowercase letter (a-z).
  • It contains at least one digit (0-9).
  • It contains at least one special character from the set !@#$%^&*()-+.

Return true if the password satisfies all of the rules, and false otherwise.

Example 1

Input
"Abcdef1!"
Output
True
Explanation:

The password has 8 characters, contains an uppercase letter ('A'), a lowercase letter ('b'), a digit ('1'), and a special character ('!'). All rules are satisfied.

Example 2

Input
"Short1!"
Output
False
Explanation:

The password is only 7 characters long, which is fewer than the required 8.

Example 3

Input
"abcdefgh1!"
Output
False
Explanation:

The password has no uppercase letter.

Example 4

Input
"ABCDEFGH1!"
Output
False
Explanation:

The password has no lowercase letter.

Loading...
Input
"Abcdef1!"
Output
True

Hello! I am your ✨ AI assistant. I can provide you hints, explanations, give feedback on your code, and more. Just ask me anything related to the problem you're working on!