Company: Deloitte_23feb
Difficulty: easy
Maximum Carrots on a Grid Path A field is represented as the cells of an M x N matrix. Every cell holds some number of carrots. A rabbit starts at the top-left cell and travels to the bottom-right cell, eating all the carrots in every cell it steps on. At each step the rabbit may move only one cell down or one cell right -- it never moves up or left. It always consumes every carrot in each cell on its path, including the starting cell and the final cell. Find the maximum number of carrots the rabbit can eat on a single trip from the top-left cell to the bottom-right cell. Input Format The first line contains two integers M and N separated by a single space -- the number of rows and the number of columns of the field. Each of the next M lines contains N space-separated integers. The j -th value on the i -th line is the number of carrots in cell (i, j) . Output Format Print a single integer Z -- the maximum number of carrots the rabbit can collect -- followed by a newline. Constraints 2