Initially it starts from (0,0) ,From here it has two moves
- either moves right
- or moves down
So, we may across the same position many times but here we across one position for one time .
This is because , before going to a position we check whether this is first time or not by checking MEM array i.e. if MEM[ i , j ] = -1 (first time) or else we have already reached it. So, total Position = R * C
=O( R * C);