Count Distinct Passwords

Problem Overview

  • Compute the variability of a password as the count of distinct strings formed by reversing any one substring of the given password.
  • Input: a lowercase English string (length 1 to 1e5); Output: a long integer count.
  • Context: password health assessment and security in real-world systems.
  • Source: Amazon interviews; a common coding interview problem and interview question.
  • Implement the function countDistinctPasswords(password) to return the total distinct results.

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Input Variables
Execution Result: