Back to problems

Combinations of Elements Using Recursive Mapping

Algorithm · Snapchat · Medium

Given a list of integers plus a lookup map, write a recursive function that returns every combination formed by selecting one string from the mapped list for each integer in the input list. Input array: A sequence of distinct integers, such as [4, 5, 6]. mapping: A map whose integer keys point to lists of strings, such as {4: ['h', 'i'], 5: ['j', 'k'], 6: ['l', 'm']}. Output Return a two-dimensional list that includes every valid selection combination. Example The result…

Checking your access…