2025-08-18 16:41:27 +0000 UTC
Strong Password Checker II
Categories:
Links
Code
class Solution:
def strongPasswordCheckerII(self, password: str) -> bool:
if len(password) < 8:
return False
has_lower, has_upper, has_digit, has_spec = False, False, False, False
prev = None
spec = "!@#$%^&*()-+"
for char in password:
if char.islower():
has_lower = True
elif char.isupper():
has_upper = True
elif char.isdigit():
has_digit = True
elif char in spec:
has_spec = True
if prev is not None and char == prev:
return False
prev = char
return has_lower and has_upper and has_digit and has_spec