Professional Documents
Culture Documents
The king of thieves Kukki has been recently released from the prison. He has a very peculiar habit of
executing his plans. Firstly he acquires the map of the place and then divide it into levels and further
sub-dividing each level thus creating a grid structure. But since he spent so many years in prison he is
out of his mind and he needs your help. Being his accomplice u need to execute the plan so as to steal
maximum profit. You will be given the overview of the map as a array of string. Each character of a
cell gives you the number of diamonds present at that location. You should start at the top-left corner
of the map ( Element (0,0) ) . On a current state you should move in accordance of the following
rules :
1. On the first traversal you should start from the upper left corner of the matrix. You can move
down or right one cell at a time ( no diagonal moves ). You need to reach at the bottom right
corner.
2. After reaching at the bottom right corner you need to again reach at the starting location
(upper left cell) by moving at each step one cell left or one cell up.
3. On arriving at this upper –left cell, you are required to go again back to the bottom –right cell.
(Don’t get mad at me.. its kukki who is responsible for this , after all this is his plan ). Now
kukki leaves the place with all the diamonds collected.
When you reach a location u collect all the diamonds placed at the cell. So now help your best
friend Kukki to collect maximum number of diamonds.
Constraints:
(Each string will be NULL terminated that is ‘\0’ , so can find number of columns. You can change
prototype slightly if u need but u need to mention it with a support file explaining your approach).
1) 0 9 0 0
0 9 9 8
0 8 9 9
9 0 0 9
Return value: 79
2) 0 2
1 2
1 2
Return Value: 8
3) 0 3 3 3 1 1 1 1 1 1
1 3 0 0 0 0 0 0 0 0
1 3 3 0 9 9 9 9 9 0
1 0 3 0 9 9 9 9 9 0
1 0 3 0 9 9 9 9 9 0
1 0 1 0 9 9 9 9 9 0
1 0 1 1 0 0 0 0 0 0
1 1 1 1 1 1 1 1 1 1
codepool.literati2k10@gmail.com
Or Contact: