Dp solution o(n.sum) time


#1


solution different from editorial