Matrix chain multiplication - top down dynamic programming