Decode the Message LeetCode solution in C++
1class Solution {2public:3string decodeMessage(string key, string message) {4vector<char> alpha{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',5'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};6int i = 0;78map<char, char> d;910for (int j = 0; j < 26; j++) {11d[alpha[j]] = '0';12}1314for (int j = 0; j < key.size(); j++) {15if (key[j] != ' ' && d[key[j]] == '0') {16d[key[j]] = alpha[i];17i++;18}19if (i == 26) break;20}21d[' '] = ' ';2223string res = "";24for (int i = 0; i < message.size(); i++) {25res += d[message[i]];26}27return res;28}29};