Tap here to switch tabs
Problem
Submissions

Problem: Decode the Message

med
30 min
Try to solve the Decode the Message problem.

Statement

You are given two strings, key and message, which represent a cipher key and a secret message, respectively.

To decode message, construct a substitution table using key according to the following steps:

  1. Traverse key from left to right and take the first appearance of each unique lowercase English letter.

  2. Map these unique letters in order to the standard 2626 lowercase English letters, mapping the first unique character to 'a', the second to 'b', the third to 'c', and so on up to 'z'.

  3. Spaces ' ' are not mapped and remain as spaces ' '.

Using the substitution table, decode every character in message and return the resulting decoded string.

Constraints:

  • 26≤26 \leq key.length ≤2000\leq 2000

  • key consists of lowercase English letters and ' '.

  • key contains every letter in the English alphabet ('a' to 'z') at least once.

  • 1≤1 \leq message.length ≤2000\leq 2000

  • message consists of lowercase English letters and ' '.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Decode the Message

med
30 min
Try to solve the Decode the Message problem.

Statement

You are given two strings, key and message, which represent a cipher key and a secret message, respectively.

To decode message, construct a substitution table using key according to the following steps:

  1. Traverse key from left to right and take the first appearance of each unique lowercase English letter.

  2. Map these unique letters in order to the standard 2626 lowercase English letters, mapping the first unique character to 'a', the second to 'b', the third to 'c', and so on up to 'z'.

  3. Spaces ' ' are not mapped and remain as spaces ' '.

Using the substitution table, decode every character in message and return the resulting decoded string.

Constraints:

  • 26≤26 \leq key.length ≤2000\leq 2000

  • key consists of lowercase English letters and ' '.

  • key contains every letter in the English alphabet ('a' to 'z') at least once.

  • 1≤1 \leq message.length ≤2000\leq 2000

  • message consists of lowercase English letters and ' '.