practice greedy algorithm and DP