Salesforce provides a secure system for organizations to manage their accounts and data. To ensure maximum security, Salesforce has implemented password policies for user accounts. A password is considered safe if it satisfies the following criteria:
Given the integers n (password length) and k (maximum allowed consecutive identical characters), calculate the total number of distinct safe passwords that can be generated. Since the number can be large, return the result modulo (10^9 + 7).
Consider n = 2, k = 2
The total number of passwords of length 2 is 26 * 26 = 676. There are 26 cases where k = 2 consecutive characters are the same. Thus, the answer is 26 * 26 - 26 = 650, and 650 modulo (10^9 + 7) = 650.
Expert in Data Structures & Algorithms. Building tools to help developers crack FAANG interviews.