C++||SIMPLE RECURSION
```\nclass Solution {\npublic:\n    bool check_valid(string s,vector &words)\n    {\n        s.erase(s.size()-1,1);\n        if(s.size() == 0) return true;\n   
```\nclass Solution {\npublic:\n    bool check_valid(string s,vector<string> &words)\n    {\n        s.erase(s.size()-1,1);\n        if(s.size() == 0) return true;\n        auto it = find(words.begin(),words.end(),s);\n        if(it == words.end()) return false;\n        return check_valid(s,words);\n    }\n    \n    string longestWord(vector<string>& words) \n    {\n        string ans="";\n        for(int i=0;i<words.size();i++)\n        {\n            bool val = check_valid(words[i],words);\n            if(val == true)\n            {\n                if(words[i].length() > ans.length() || (words[i].length()==ans.length() && words[i] < ans)) ans = words[i];\n            }\n        }\n        return ans;\n    }\n};
[]