update last element in dynamic programming array