C++ | Vector | Very easy to understand!
Pls upvote if you like my solution!\n\n# Approach\nJust adding all the elements(string) in a vector and when search() is called traversing every element of vect
# *Pls upvote if you like my solution!*\n\n# Approach\nJust adding all the elements(string) in a vector and when search() is called traversing every element of vector from start and check whether the given string is equal to the string in the vector.\n\n- **void addWord(string word)**:- Push the string in the vector.\n- **bool search(string word)**:- Traverse through the whole string and check whether **v[i]==word** (for this first check if there size is equal then proceed for checking each and every element just the catch is that if **\'.\'** occcurs then consider the **ith element** as equal). \nif **count==word.size()** return true else check for next element in the vector. At last return false if any of the above condition doesn\'t matches.\n\n# Code\n```\nclass WordDictionary {\npublic:\n    vector<string> v;\n    WordDictionary() {\n        \n    }\n    \n    void addWord(string word) {\n        v.push_back(word);\n    }\n    \n    bool search(string word) {\n        int count=0;\n        int n=word.size();\n        for(int i=0; i<v.size(); i++){\n            if(n==v[i].size()){\n                for(int j=0; j<n; j++){\n                    if(v[i][j]==word[j]||word[j]==\'.\'){\n                        count++;\n                    }\n                    else{\n                        count=0;\n                        break;\n                    }\n                }\n                if(count==n) return true;\n            }\n        }\n        return false;\n    }\n};\n
['String', 'Design', 'C++']