Nasdaq Interview Question

One was simple problem where GREEDY approach worked. Another was a Medium-High DP problem.