In this lesson, Alvin explores the strategy to solving the following interview problem:
Write a function sum_possible that takes in an amount and a list of positive numbers. The function should return a boolean indicating whether or not it is possible to create the amount by summing numbers of the list. You may reuse numbers of the list as many times as necessary.
You may assume that the target amount is non-negative.
sum_possible(8, [5, 12, 4]) # -> True, 4 + 4
sum_possible(15, [6, 2, 10, 19]) # -> False
sum_possible(13, [6, 2, 1]) # -> True
sum_possible(103, [6, 20, 1]) # -> True
If you need additional support taking these DSA skills and actually applying them, take Alvin's complete data structures and algorithms course on Structy. You can try out the concepts yourself in their interactive code editor and learn advanced DSA patterns like stack exhaustive recursion.
Use this link to get 20% off the entire Structy DSA learning experience.
Follow Alvin on LinkedIn: https://www.linkedin.com/in/alvin-zablan-b73a92117/