Pregunta de entrevista de Salesforce

Asked 2d dynamic programming question.