dp and reverse list