摘要: DFS。AC的代码class Solution {public:bool flag;bool used[250][250]; bool exist(vector<vector<char> > &board, string word) { if(word=="")return true; int m=board.size(); if(m==0)return false; int n=board[0].size(); flag=false; for(int i=0;i<m;i++) { ... 阅读全文
posted @ 2013-06-09 17:07 代码改变未来 阅读(842) 评论(0) 推荐(0) 编辑
摘要: 1.Search for a Range参考剑指offer 面试题38class Solution {public: vector searchRange(int A[], int n, int target) { vectorindex; int low=0,high=n-1; int m; while(low=0&&A[i]==target;i--); index.push_back(i+1); for(j=m;jtarget)high=m-1; ... 阅读全文
posted @ 2013-06-09 15:02 代码改变未来 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 不多说了。class Solution {public: void setZeroes(vector<vector<int> > &matrix) { int m=matrix.size(); if(m==0)return; int n=matrix[0].size(); vector<int>a; vector<int>b; for(int i=0;i<m;i++) { for(int j=0;j<n;j++) { ... 阅读全文
posted @ 2013-06-09 14:41 代码改变未来 阅读(185) 评论(0) 推荐(0) 编辑
摘要: Surrounded RegionsDFSclass Solution {public: void solve(vector<vector<char>> &board) { int n=board.size(); if(n==0)return; for(int i = 1; i < n- 1; i++) { dfs(board, i, 0); dfs(board, i, n-1); } for(int j = 0; j ... 阅读全文
posted @ 2013-06-09 00:17 代码改变未来 阅读(1337) 评论(0) 推荐(0) 编辑