Pergunta de entrevista da empresa Tesla

QUESTION 1: In example_system_1, the step for "output3" takes inputs from the steps for "output1" and "output2". Thus, if the user requests "output3", we must first evaluate the actions for "output2" and "output1" to get the values of these outputs, so the values can be used as inputs to the action of "output3". To determine the correct ordering of step dependencies, complete the action_evaluation_order() function below, so that it will return a list of "output_name"s needed for the "order_for_output_name" parameter. Each "output_name" item in the list should appear *after* any of its dependencies. The ordering should not contain any duplicates. You may assume every list of "StepDeclarations" is valid and solvable, eg: - each "StepDeclaration" will only have one output - each "StepDeclaration" can have any number of dependencies (including 0) - a list of StepDeclarations will not contain duplicate "output_name"s - a "StepDeclaration" cannot depend on its own output (directly or indirectly) For this and the following questions, assume in real life the system is running at a large scale, so efficiency is important. That said, correct slow solutions will get more marks than incorrect fast ones. You may also leave notes explaining where you further optimize if you had the time.