Two-dimensional Dynamic Programming
145 / 170Two-dimensional Dynamic ProgrammingLesson 10 of 11About 60 min
The last problem in the unit, and the one whose transitions need the most care per branch.
Every problem across both units came from the same four questions: what is a subproblem, what does its answer mean, how does it relate to smaller ones, and what is the smallest case.
Answering those in writing before touching the keyboard is the whole method. Nothing in either unit required a trick that those four questions would not produce.
A star applies to the character before it and can stand for any number of copies, including none. Type the four lines it prints.
pattern = "a*b" for count in range(4): print(f"a* as {count} copies ->", "a" * count + "b") print("so a* consumes:", "nothing, or one or more a characters")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.