Backtracking
98 / 170BacktrackingLesson 5 of 10About 34 min
Nothing new in the search. The choices at each level are looked up rather than computed.
Each level of the search draws its choices from a table keyed on the input. Type the three lines it prints.
OPTIONS = {"a": "12", "b": "345", "c": "6"} for text in ("ab", "abc", "c"): counts = [len(OPTIONS[ch]) for ch in text] total = 1 for count in counts: total *= count print(text, "->", counts, "->", total, "results")Read the constraints first and let them tell you what complexity is expected. Derive the approach, implement it, run the tests, and submit when it passes.