in order && inverse order dp