Amazon Interview Question

trees , dp solution for backtracking problems