Pergunta de entrevista da empresa GitHub

You get a string with operation as input: if it is a number push it to stack if it is "DUP", then duplicate the one one top and push it to the stack if it is "POP" then remove the one on top if it is "+" add the two numbers on top of the stack and replace both with the result of the addition if it is "-" then minus the two numbers on top (the second minus the first) of the stack and replace both with the result of the subtraction if an error occurs, e.g. not enough numbers to add/subtract/pop, then return -1 Examples: Input: "3 DUP 5 - -" Output: -1 Input: "13 DUP 4 POP 5 DUP + DUP + -" Output: 7 Input: "5 6 + -" Output: -1