This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
private: | |
bool dfs(vector<vector<char>>&board, int count, int i, int j, string& word) | |
{ | |
if(word.size() == count) //Signifies that we have reached the end of search | |
return true; | |
if(i<0 || j<0 || i>=board.size() || j>=board[0].size() || board[i][j]!=word[count]) | |
return false; | |
//We check if element is within bounds and then check if the character at that is the same as the corresponding character in string word |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// using chaining | |
class MyHashSet { | |
vector<list<int> *> hashSet; | |
const int CAP = 1000; | |
public: | |
/** Initialize your data structure here. */ | |
// initializing with nullptr allows you not to create unnecessary space until needed i.e. on add | |
MyHashSet() { | |
hashSet = vector<list<int> *>(CAP, nullptr); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution { | |
void printArray(vector<char> arr){ | |
cout<<"["; | |
for(auto c: arr){ | |
cout<<c<<","; | |
} | |
cout<<"]"<<endl; | |
} | |
vector<char> stringToArrLower(string s){ |