Problem
Ask
Submissions

Problem: Strong Password Checker

med
30 min
Explore how to use greedy algorithms to check and improve password strength. Learn to identify weaknesses such as length, character variety, and repeated characters. This lesson guides you through optimizing password changes with insertion, deletion, or replacement steps to meet security standards.

Statement

A password is deemed strong if it satisfies all of the following criteria:

  • Its length is at least 66 and at most 2020 characters.

  • It contains at least one lowercase letter, at least one uppercase letter, and at least one digit.

  • It does not contain three or more identical characters consecutively (e.g., "Baaabb0" is weak, but "Baaba0" is strong).

Given a string, password, determine the minimum number of steps needed to make password strong. If it is already strong, return 00.

In a single step, you may perform exactly one of the following operations:

  • Insert one character into password.

  • Delete one character from password.

  • Replace one character in password with a different character.

Constraints:

  • 11 \leq password.length 50\leq 50

  • password consists of letters, digits, dot '.', or exclamation mark '!'.

Problem
Ask
Submissions

Problem: Strong Password Checker

med
30 min
Explore how to use greedy algorithms to check and improve password strength. Learn to identify weaknesses such as length, character variety, and repeated characters. This lesson guides you through optimizing password changes with insertion, deletion, or replacement steps to meet security standards.

Statement

A password is deemed strong if it satisfies all of the following criteria:

  • Its length is at least 66 and at most 2020 characters.

  • It contains at least one lowercase letter, at least one uppercase letter, and at least one digit.

  • It does not contain three or more identical characters consecutively (e.g., "Baaabb0" is weak, but "Baaba0" is strong).

Given a string, password, determine the minimum number of steps needed to make password strong. If it is already strong, return 00.

In a single step, you may perform exactly one of the following operations:

  • Insert one character into password.

  • Delete one character from password.

  • Replace one character in password with a different character.

Constraints:

  • 11 \leq password.length 50\leq 50

  • password consists of letters, digits, dot '.', or exclamation mark '!'.