✅ C++ || ✅Using DFS || ✅Comments Added || ✅Easy To Learn
\nclass Solution {\npublic:\n    bool dfs(int i,int j,int count,vector<vector<char>>& board,string word)\n    {\n        // if we have found the whole string th
```\nclass Solution {\npublic:\n    bool dfs(int i,int j,int count,vector<vector<char>>& board,string word)\n    {\n        // if we have found the whole string then count will become (word.length()==count) so return true\n        if(word.length()==count) return true;\n        \n        // check for boundary                                  // curr char is not same with word char\n        if(i<0 || i>=board.size() || j<0 || j>=board[0].size() || board[i][j] != word[count])\n            return false;\n        \n        \n        \n        char temp = board[i][j];                    // curr char\n        board[i][j] = \' \';                          // mark as visited\n        \n        \n        // up , down , left , right (possible moves)\n        bool ans = dfs(i-1,j,count+1,board,word) || \n                   dfs(i+1,j,count+1,board,word) ||\n                   dfs(i,j-1,count+1,board,word) ||\n                   dfs(i,j+1,count+1,board,word);\n        \n        board[i][j] = temp;                         // make board as it is for the upcoming calls\n        return ans;\n    }\n    \n    bool exist(vector<vector<char>>& board, string word) \n    {\n        int n = board.size();                   // rows\n        int m = board[0].size();                // cols\n        \n        for(int i=0;i<n;i++)\n        {\n            for(int j=0;j<m;j++)\n            {\n                if(board[i][j]==word[0] && dfs(i,j,0,board,word))                // whenever we found first letter of word start searching from there\n                {\n                    return true;\n                }\n            }\n        }\n        \n        return false;\n    }\n};\n```
['Depth-First Search', 'Recursion']