All, I've good a Memory Limit Exceeded message in my sumission, However I am not using any extra memory structures. Can any one spot the problem:

class Solution {

public:

int islandPerimeter(vector<vector<int>>& grid) {

int p=0;

for(unsigned int i = 0; i< grid.size() ; ++i){

for(unsigned int j = 0; j< grid[i].size() ; ++j){

if(!grid[i][j]){ continue; }

if( (i==0) || (!grid[i-1][j]) ){p++;}

if( (i==grid.size()-1) || (!grid[i+1][j]) ){p++;}

if( (j==0) || (!grid[i][j-1]) ){p++;}

if( (j==grid[i].size()-1) || (!grid[i][j+1]) ){p++;}

}

}

return p;

}

};