DP solution to minCut
solution to reverse