2325. 解密消息 
为保证权益,题目请参考 2325. 解密消息(From LeetCode).
解决方案1 
CPP 
C++
#include <map>
#include <string>
using namespace std;
class Solution {
 public:
  string decodeMessage(string key, string message) {
    map<char, char> convertMap = [](const string& key) {
      map<char, char> cm;
      int kiter = 0;
      for (const char ch : key) {
        if (int(ch) >= 'a' && int(ch) <= 'z') {
          if (cm.find(ch) == cm.end()) {
            cm[ch] = char(kiter + 'a');
            kiter += 1;
          }
        }
      }
      return cm;
    }(key);
    string ans;
    for (const char ch : message) {
      if (int(ch) >= 'a' && int(ch) <= 'z') {
        ans.push_back(convertMap[ch]);
      } else {
        ans.push_back(ch);
      }
    }
    return ans;
  }
};1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33