Description
You are given the strings key and message. Decode message using a substitution cipher where the first occurrence of each letter in key maps to the alphabet in order.
Examples
Input:
key = "the quick brown fox jumps over the lazy dog", message = "vkbs bs t suepdings"Output:
"this is a]$cret"Explanation:
Substitution decoding.
Input:
key = "a", message = "a"Output:
"this is a]$cret"Explanation:
Decoding a single character using the substitution cipher defined by the key.
Input:
key = "programming challenges are fun and educational today", message = "kifv wfvvsgf"Output:
this messageExplanation:
The key creates a substitution cipher where each unique letter in the key maps to letters a-z in order of first appearance. 'p' maps to 'a', 'r' to 'b', 'o' to 'c', etc. The message 'kifv wfvvsgf' is decoded using this mapping to produce 'this message'.
Constraints
- •
26 ≤ key.length ≤ 2000