solution for max profit 2