Tech Mahindra Interview Question

dp related problems, array related for problems