Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions C++/Word_Search.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class Solution {
public:

bool dfs(vector<vector<char>>& board,int i,int j,int count,string word)
{
if(count==word.length())
return true;
if(i<0||i>=board.size()||j<0||j>=board[i].size()||board[i][j]!=word[count])
return false;

char temp = board[i][j];
board[i][j]=' ';
bool found = dfs(board,i+1,j,count+1,word)||dfs(board,i,j+1,count+1,word)||dfs(board,i-1,j,count+1,word)||dfs(board,i,j-1,count+1,word);
board[i][j]=temp;
return found;
}

bool exist(vector<vector<char>>& board, string word) {

for(int i=0;i<board.size();i++)
{
for(int j=0;j<board[i].size();j++)
{
if(board[i][j]==word[0]&& dfs(board,i,j,0,word))
return true;
}
}
return false;
}
};
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,8 @@ DISCLAIMER: This above mentioned resources have affiliate links, which means if
| [Meli Haktas](https://github.com/MercerFrey) <br> <img src="https://avatars1.githubusercontent.com/u/29127873?s=460&u=149319db4468ec2316e49a75eb5e05b35eb05eef&v=4" width="100" height="100"> | Turkey | python | [Github](https://github.com/MercerFrey) |
| [Saurav Prateek](https://github.com/SauravP97) <br> <img src="https://avatars3.githubusercontent.com/u/26816418?s=460&u=4b5222d5b6db79389efba062714c9dfba263732f&v=4" width="100" height="100"> | India | Java | [Github](https://github.com/SauravP97) <br> [Codechef](https://www.codechef.com/users/srvptk) <br> [Codeforces](https://codeforces.com/profile/srvptk97) <br> [Leetcode](https://leetcode.com/srvptk97) |
| [Anushka Verma](https://github.com/verma-anushka) <br> <img src="https://avatars0.githubusercontent.com/u/46157435?s=400&u=aa3db9cf25b4a9644a16607d0c8bd6c98763a62d&v=4" width="100" height="100"> | India | C++ | [Portfolio](https://verma-anushka.github.io/anushkaverma/) <br> [LeetCode](https://leetcode.com/anushka_verma/) |
| [James H](https://github.com/HoangJames) <br> <img src="https://avatars2.githubusercontent.com/u/15057250?s=460&v=4" width="100" height="100"> | United Kingdom | C++ | [Github](https://github.com/HoangJames) |
| [James H](https://github.com/HoangJames) <br> <img src="https://avatars2.githubusercontent.com/u/15057250?s=460&v=4" width="100" height="100"> | United Kingdom | C++ | [Github](https://github.com/HoangJames)
| [Aviral Tandon](https://github.com/aviraltandon21) <br> <img src="https://github.com/aviraltandon21.png" width="100" height="100"> | India | C++ | [Linkedin](https://www.linkedin.com/in/aviral-tandon-b852891a1/) <br> [Portfolio](https://aviraltandon.com/) | |
| [Franchis N. Saikia](https://github.com/Francode007) <br> <img src="https://avatars0.githubusercontent.com/u/63102937?s=400&v=4" width="100" height="100"> | India | C++ | [Github](https://github.com/Francode007) |
| [Yarncha](https://github.com/yarncha) <br> <img src="https://avatars0.githubusercontent.com/u/33623182?s=400&v=4" width="100" height="100"> | South Korea | C++ | [LeetCode](https://leetcode.com/yamcha/) |
| [Gamez0](https://github.com/Gamez0) <br> <img src="https://avatars3.githubusercontent.com/u/34051876?s=400&v=4" width="100" height="100"> | South Korea | Python | [LeetCode](https://leetcode.com/Gamez0/) |
Expand Down