PROBLEM LINK:Author: Jatin Gupta DIFFICULTY:EASY PREQUISITESBasic knowledge of modulo operator PROBLEM:To find the length of longest palindrome that can be made by taking a subset of given string after decrypting it. QUICK EXPLANATION:First decrypt the string by applying inverse operation of the given encrypt function. After this, note that we can take even numbers of each character(Put that character at the beginning and end of the current answer string) and also 1 character separately that can be put in the middle.(if it exists) EXPLANATION:First step is to decrypt the given string: Since we are given a pseudocode in which there is statement for encryption given as follow: So, for decryption we have to do opposite of encryption i.e., But here the problem is that id will make the modulo negative so for keeping it positive we have to add 26 to it so that the resultant lies is positive and also lies in the range of alphabets …
So the new statement is : After decryption, it is now to find the maximum palindromic subset in the string decrypted above. First of all it is necessary to know that a palindromic string has two parts
Single character can at maximum occur once while we can have as many as doubles possible. Since we have to find the subset and then arrange, so order in string does not matter. Now there can be two cases
If we had even count for any character, we can add 1 to the answer AUTHOR'S AND TESTER'S SOLUTIONS:Author's solution can be found here. asked 24 Apr '18, 22:23
