Tap here to switch tabs
Problem
Ask
Submissions

Problem: Strong Password Checker

med
30 min
Discover how to determine and enhance password strength by applying greedy algorithm methods. This lesson helps you understand the criteria for a strong password and teaches steps to optimize password validation and modification efficiently.

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 '!'.

Tap here to switch tabs
Problem
Ask
Submissions

Problem: Strong Password Checker

med
30 min
Discover how to determine and enhance password strength by applying greedy algorithm methods. This lesson helps you understand the criteria for a strong password and teaches steps to optimize password validation and modification efficiently.

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 '!'.