294. Strong Password Checker (Minimum Steps)

HardStringString

A password is strong if it has at least 6 and at most 20 characters, contains at least one lowercase letter, one uppercase letter, and one digit, and does not contain three repeating characters in a row. Given a string password, return the minimum number of steps (insert, delete, or replace a character) to make it strong.

Input: A quoted password string.

Output: Integer — minimum steps.

Examples

Example 1
Input: "a"
Output: 5
Explanation: Needs length and char types.
Example 2
Input: "aA1"
Output: 3
Explanation: Length to 6.
Example 3
Input: "1234567890"
Output: 2
Explanation: Add lower and upper.

Constraints

Asked by

MicrosoftGoogleBloombergAmazonMeta
Solve this problem in the editor →