dynamic and greedy algo for longest increasing sequence