#2299

Strong Password Checker II

pupil · 420 · lc easy +25 · verified · 55.3% accepted · 382 likes · top 48%

Description

A password is considered strong if all of these conditions hold:

- It has at least 8 characters.

- It includes at least one lowercase letter.

- It includes at least one uppercase letter.

- It includes at least one digit.

- It includes at least one special character from "!@#$%^&*()-+".

- No two adjacent characters are the same.

Given a string password, return true if it is strong, or false otherwise.

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.

Code

1
2
3