dp_prob_2 space O(1)