摘要:
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++) { ... 阅读全文
摘要:
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; ... 阅读全文
摘要:
不多说了。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++) { ... 阅读全文
摘要:
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 ... 阅读全文