Given a transmission string and a decoding dictionary, replace all occurrences of alien codes with their corresponding Earth language values in the dictionary, if the code exists in the dictionary, otherwise leave it unchanged.
Explanation: Step-by-step: 1. Split the input string into substrings of length 2: ['he', 'll', 'o', 'h', 'el', 'lo', 'fo', 'oo', 'xy']. 2. For each substring, check if it exists in the decoding dictionary. If it does, replace it with its corresponding Earth language value. If it doesn't, leave it unchanged. 3. Join the resulting substrings back into a single string to get the output.
Explanation: Step-by-step: 1. Split the input string into substrings of length 2: ['fo', 'ba', 'ra', 'bo', 'ar', 'xy']. 2. For each substring, check if it exists in the decoding dictionary. If it does, replace it with its corresponding Earth language value. If it doesn't, leave it unchanged. 3. Join the resulting substrings back into a single string to get the output.
Master coding challenges related to Strings and solve the [Backup] Galactic Transmission Decoding problem optimally.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak