#420
Strong Password Checker
grandmaster · 2340 · lc hard +32 · verified · 15.5% accepted · 961 likes · top 0%
Description
A password qualifies as strong when all of the following hold:
- Length falls between 6 and 20 characters inclusive.
- It includes at least one lowercase letter, one uppercase letter, and one digit.
- It has no run of three or more consecutive identical characters ("Baaba0" is strong; "Baaabb0" is not).
Given password, return the fewest insertions, deletions, or single-character replacements needed to make it strong. Return 0 if it is already strong.
Example 1:
Input: password = "a"
Output: 5
Example 2:
Input: password = "aA1"
Output: 3
Example 3:
Input: password = "1337C0d3"
Output: 0
Code
1
2
3