This is a verified interview question from Fidelity-investment. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Secret Password Generator - Fidelity investment Online Assessment" covers key patterns like Arrays.
"A university encrypts the names of examination papers before sending them to affiliated colleges. Each paper name is transformed using a secret integer key `K`, and the encrypted result serves as the password required to unlock the corresponding file. The encryption process works as follows: 1. Start with the paper name `P` and an integer key `K` (which may be positive, negative, or zero). 2. Only lowercase English letters (`a-z`) are encrypted. 3. Every lowercase letter is shifted by `K` positions in the alphabet. 4. Uppercase letters, digits, spaces, and special characters remain unchanged. 5. The lowercase alphabet is considered circular: * If shifting forward goes beyond `'z'`, continue again from `'a'`. * If shifting backward goes before `'a'`, continue again from `'z'`. Generate the encrypted string after applying the above transformation. --- ## Input Format * The first line contains a string `P`, representing the paper name. * The second line contains an integer `K`. --- ## Output Format Print the encrypted string. --- ## Constraints * `1 ≤ |P| ≤ 50` * `-50 ≤ K ≤ 50` --- ## Sample Input 1 ```text id="in1" Operating Systems -40 ``` ## Sample Output 1 ```text id="out1" OlqjAting Systems ``` --- ## Explanation Only lowercase letters are shifted by `-40` positions (equivalent to shifting by `12` positions backward modulo `26`). Uppercase letters and spaces remain unchanged. --- ## Sample Input 2 ```text id="in2" hello123! 5 ``` ## Sample Output 2 ```text id="out2" mjqqt123! ``` --- ## Sample Input 3 ```text id="in3" xyz 4 ``` ## Sample Output 3 ```text id="out3" bcd ``` ---"
Join thousands of developers practicing for Fidelity-investment.