Question: Language Python 3 Autocomplete Ready O 2. Maximum Path Your goal is to find the maximum path value of viable paths in a pyramid. A

Language Python 3 Autocomplete Ready O 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> #!/bin/python3... 10 11 # 12 # Complete the maximum_path' function below. 13 # 14 # The function is expected to return an INTEGER. 15 # The function accepts INTEGER_ARRAY node_values as parameter. 16 # 17 18 19 def maximum_path(node_values): 20 # Write your code here 21 22 v if __name__ == '__main__': 23 fptr = open(os.environ['OUTPUT_PATH'], 'w') 24 25 node_values_count = int(input().strip) 26 27 node_values = [] 28 29 for - in range (node_values_count): 30 node_values_item = int(input().strip) 31 node_values.append(node_values_item) 32 33 result = maximum_path(node_values) 34 35 fptr.write(str(result) + ' ') 36 37 fptr.close() 38 -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. Test Results Custom Input
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
