3
void solve(string digit, string output, int index, vector<string> &ans,4
string mapping[]) { // base condition5
if (index >= digit.length()) {9
// digit[index] gives character value to change in integer subtract '0'10
int number = digit[index] - '0';11
// get the string at perticular index in mapping12
string value = mapping[number];13
// runs loop in value string and push that value in out put string ans do14
// recursive call for next index15
for (int i = 0; i < value.length(); i++) {16
output.push_back(value[i]);17
solve(digit, output, index + 1, ans, mapping);19
// backtrach because initially output is empty and one case solves now you20
// have to solve second case in similar way25
vector<string> letterCombinations(string digits) {27
// if it is empty input string28
if (digits.length() == 0) {33
// map every index with string34
string mapping[10] = {"", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};35
solve(digits, output, index, ans, mapping);