Add second method using two dimensional matrix, so called Dynamic Programming method

add main test for a simple test case