This is a verified interview question from Salesforce. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Safe Salesforce Passwords" covers key patterns like DP.
"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: 1. The length of the password is exactly n. 2. The password consists of lowercase English characters only. 3. The password does not contain k or more consecutive identical characters. 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). ### Example 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."
Join thousands of developers practicing for Salesforce.