JuniorString

Strong Password Checker II

A password is said to be strong if it satisfies all the following criteria:

  • It has at least 8 characters.
  • 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 2 of the same character in adjacent positions (i.e., "aab" violates this condition, but "aba" does not).

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

Example 1
Inputpassword = "IloveLe3tcode!"
Outputtrue
The password meets all the requirements, so we return true.
Example 2
Inputpassword = "Me+You--IsMyDream"
Outputfalse
The password does not contain a digit and also contains 2 of the same character in adjacent positions, so we return false.

Constraints

  • 1 <= password.length <= 100
  • password consists of letters, digits, and special characters: "!@#$%^&*()-+".

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate