Strong Password Checker
A password is considered strong if all of the following conditions are met:
- It has at least
6characters and at most20characters. - It contains at least one lowercase letter, at least one uppercase letter, and at least one digit.
- It does not contain three repeating characters in a row.
Given a string password, return the minimum number of steps required to make password strong. If password is already strong, return 0.
In one step, you can:
- Insert one character into
password. - Delete one character from
password. - Replace one character of
passwordwith another character.
Example 1
Input
password = "a"Output
5The password needs five insertions or replacements to satisfy the length and character-type requirements.
Example 2
Input
password = "aA1"Output
3The password already has lowercase, uppercase, and digit characters, but needs three more characters to reach the minimum length.
Constraints
- 1 <= password.length <= 50
- password consists of letters, digits, dot
'.'or exclamation mark'!'.