Back to Bill.com questions
CodingSoftware Engineer

Password Sanitizer

Frequency: Reported


Create a Java class named PasswordSanitizer with a utility method named filter. It accepts a list of passwords and removes every password that fails either rule:

  • length must be at least five;
  • the password cannot consist entirely of letters or entirely of numbers.

Return the valid passwords in original order as one space-separated string.

Example

text
input:
p@c1 pass@123 word@321 wordpass 987345

output:
pass@123 word@321

p@c1 is too short, wordpass contains only letters, and 987345 contains only digits.

Constraints

  • No password contains whitespace.
  • At least one password is valid.
  • Passwords may contain English letters, digits, and special characters.

The screenshot did not preserve the complete Java method signature or input-size bounds.