← Back to index
HardPHP5 min read

Strong Password Checker

find minimum steps to make password strong by handling length, character types, and repeating sequences.

greedystring

Problem link

View on LeetCode

Solutions in this repo

  • PHP../strong-password-checker/solution.phpPHP solution

handle three cases: too short, too long, just right. for each, count missing character types and repeating sequences. prioritize fixes that solve multiple issues.

for long passwords, use deletions to break repeating sequences efficiently. for short passwords, use insertions. for correct length, use replacements.

requirements

  • length 6-20
  • contains lowercase, uppercase, digit
  • no three consecutive same characters

complexity

O(n) time to scan password and count issues. O(1) space. greedy approach handles all cases.