Company: Goldman sachs_25july
Difficulty: medium
Secure my conversations Problem Description Persons A and B uses an encryption based system for their conversation. Each conversation message is encoded from the source and decoded in the destination using a shared private positive number key known to each other. The algorithm is illustrated with an example. Input Format with explanation: 1. Operation (1 for Encoding and 2 for Decoding) 2. Input message 3. Input private key Output Format with explanation: 1. Output message The conversation message and the private key need NOT be in equal length and the encoding / decoding takes place till the end is reached in either the conversation message or private key, while retaining the rest of the conversation message. Returns -1 in all exception scenarios Examples Example 1: Input: 1 Open 123 Output: Oppeenn Explanation: Here, the input message characters are duplicated based on each digit in the key. Example 2: Input: 2 Oppeenn 123 Output: Open Explanation: Here, the input message characters