Company: Goldman Sachs OA

Difficulty: medium

Problem Statement

Secure my conversations Persons A and B use an encryption based system for their conversation. Each conversation message is encoded at the source and decoded at the destination using a shared private positive number key that both of them know. The key is written as a string of decimal digits, and the digits are consumed one at a time alongside the characters of the message. Encoding (operation 1 ): pair the first character of the message with the first digit of the key, the second character with the second digit, and so on. A character paired with the digit d is written out d times in a row. The conversation message and the private key need not have equal length, so the pairing stops as soon as the end of either the message or the key is reached, and whatever is left of the conversation message after that point is copied to the output unchanged. Decoding (operation 2 ): the reverse. Walk the digits of the key from left to right; a digit d consumes the next d characters of the encoded m

More Goldman Sachs OA OA questionsInterview experiences