Jump Trading
Interview Question
Task 1: You are given a string containing only numbers and the mathematical operators '+' and '*'. Read the string character by character. If it is a digit, push it onto a stack. If it is an operator, pop two elements from the stack, apply the operator, and push the result onto the stack. If there are not enough elements on the stack or no operator to apply, return -1. For example, for '12+4*7*', the result should be 84. Task 2: You have three ticket options: a 1-day ticket for $2, a 7-day ticket for $7 (valid for 7 consecutive days), and a 30-day ticket for $25. Given a list of days (integers in increasing order) on which you plan to travel, return the minimum possible amount of money you need to spend on tickets. For example, given [1,2,3,4,5,11,12,25], the minimum possible cost is 13.
Unlock the Full Solution
Enter your email to get instant access to the complete solution, explanation, and similar practice problems.

