Company: Dp World_28aug
Difficulty: medium
Valid Passwords Problem Description A bank requires passwords to meet specific security requirements. Given two integers n and k , a password is valid if: The length of the password is n The password consists of lowercase English letters only The password does not contain k consecutive equal letters Find the number of distinct valid passwords possible, modulo (10 9 +7). Examples Example 1: Input: n = 2, k = 2 Output: 650 Explanation: The total number of passwords of length 2 is 26 * 26 = 676. There are 26 cases where k = 2 consecutive characters are the same (e.g., "aa", "bb", ..., "zz"). Therefore, the answer is 676 - 26 = 650. Example 2: Input: n = 3, k = 3 Output: 17550 Explanation: The number of passwords possible of length 3 is 26 * 26 * 26. Subtract the cases where all the characters are the same (26 such cases). The number of valid passwords is 26 * 26 * 26 - 26 = 17550 and 17550 % (10 9 + 7) = 17550. Example 3: Input: n = 3, k = 2 Output: 16250 Explanation: The number of passwo