add in-place DP solution for triangle