Class Solution
-
- All Implemented Interfaces:
public final class Solution2299 - Strong Password Checker II.
Easy
A password is said to be strong if it satisfies all the following criteria:
It has at least
8characters.It contains at least one lowercase letter.
It contains at least one uppercase letter.
It contains at least one digit.
It contains at least one special character. The special characters are the characters in the following string:
"!@#$%^&*()-+".It does not contain
2of the same character in adjacent positions (i.e.,"aab"violates this condition, but"aba"does not).
Given a string
password, returntrueif it is a strong password. Otherwise, returnfalse.Example 1:
Input: password = "IloveLe3tcode!"
Output: true
Explanation: The password meets all the requirements. Therefore, we return true.
Example 2:
Input: password = "Me+You--IsMyDream"
Output: false
Explanation: The password does not contain a digit and also contains 2 of the same character in adjacent positions. Therefore, we return false.
Example 3:
Input: password = "1aB!"
Output: false
Explanation: The password does not meet the length requirement. Therefore, we return false.
Constraints:
1 <= password.length <= 100passwordconsists of letters, digits, and special characters:"!@#$%^&*()-+".
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final BooleanstrongPasswordCheckerII(String password)-
-
Method Detail
-
strongPasswordCheckerII
final Boolean strongPasswordCheckerII(String password)
-
-
-
-