Question: 2. Maximum Path Your goal is to find the maximum path value of viable paths in a pyramid. A viable path is one where you



2. Maximum Path Your goal is to find the maximum path value of viable paths in a pyramid. A viable path is one where you take at most one step to the left or right as you progress down the nodes of the pyramid. You must pass through every level. The total path value is the sum of the values in the nodes traversed by your path. The diagram below represents a simple 3-layer pyramid with 4 possible paths: 1 3 -1 3 5 In the above example, the correct answer is 7, which is achieved by the blue path. The black (1), red paths (5) and green (5) lines are represent viable paths, but do not achieve the highest value. Data will be presented to you as a 1D array of integers, so in the case of the above example, your function will receive an array [1, 3, -1, 3, 1, 5] as input and will be expected to produce the integer 7 as output. G Language Python 3 Autocomplete Ready O ... 1 > #!/bin/python3. 10 11 # 12 13 14 # Complete the 'maximum_path' function below. # # The function is expected to return an INTEGER. # The function accepts INTEGER_ARRAY node_values as parameter. # 15 16 17 18 def maximum_path(node_values): 19 20 21 > if __name '__main__
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
