Given an array of digits (0-9) of length 'n', and a list of characters corresponding to every digit, develop an a'rithm to generate all possible strings.
Example:
Input: array A = [0, 1, 2], n = 3, charMap[0] = ['a', 'b', 'c'], charMap[1] = ['d', 'e', 'f', 'g'], charMap[2] = ['h', 'i']
Output: total 3*4*2 = 24 such strings are possible, as follows:
adh
adi
aeh
aei
afh
afi
agh
agi
bdh
bdi
beh
bei
bfh
bfi
bgh
bgi
cdh
cdi
ceh
cei
cfh
cfi
cgh
cgi
The Road Not Taken is Guaranteed Minimum Income
2 weeks ago
1 comment:
Is there a better algo than the obvious exponential one?
Post a Comment