solved Stock Maximize from HackerRank