i understood and you will also understand it using this video...beginner frinedly||c++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nhttps://youtu.be/WgP3vDulzDU?si=QPVRH5Ialpru2Wts\n Describe your approach
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nhttps://youtu.be/WgP3vDulzDU?si=QPVRH5Ialpru2Wts\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n//https://youtu.be/WgP3vDulzDU?si=QPVRH5Ialpru2Wts\n//i am going to paste the link of video from where i understood it...at first i treid the brute force way of recursion i.e take and not_take wala approach\n\n//tumko isme bas yhi dekhna hai bhai ki agr isko le le ham ek moove invest krke to hame ye fix pta krna hoga ki age jo next me hai na vo atleast inse ho hi jana chaiye \n    vector<int> validSequence(string word1, string word2) {\n        //agr matched hai...to hame ye bta do ki iske bad fix hai na ki jo left subsequence hai vo word1 me hai..agr han to break kr jaw and simply unke index ko push kr lo\n        //video me yhi hint hai bhai\n        vector<int>ans;\n        vector<int>maxlengthequal(word1.size());//kyuki actual me to tu word1 me hi dekh rhA HGA na ki age wala match ho rha hai yah nhi word2 wale se,....isliye utne lenght ka lena pada hame\n        int i=word1.size()-1;\n        int j=word2.size()-1;\n        int k=word1.size()-1;\n        while(i>=0 && j>=0)\n        {\n            if(word1[i]==word2[j])\n            {\n                maxlengthequal[k]=word2.size()-j;\n                i--;\n                j--;\n                k--;\n            }\n            else\n            {\n                i--;\n                k--;\n            }\n        }\n        for(int i=maxlengthequal.size()-2;i>=0;i--)\n        {\n           if(maxlengthequal[i]==0)\n           {\n            //to uske age wala se replace kro\n            maxlengthequal[i]=maxlengthequal[i+1];\n           }\n        }\n\n       i=0;\n       j=0;\n       int store=0;\n\n     \n       while(i<word1.size() && j<word2.size())\n       {\n        if(word1[i]==word2[j])\n        {\n             \n           \n              ans.push_back(i);\n                i++;\n                j++;\n            }\n\n        \n        else\n        {\n            //equal nhi hai\n             if(i+1<word1.size() && maxlengthequal[i+1]>=word2.size()-(j+1))//with extra one m0ove\n            {\n              \n          \n                ans.push_back(i);\n                store=i+1;\n                break;\n            }\n            else\n            {\n                i++;\n            }\n\n        }\n       }\n      \n      j=j+1;\n      \n       for(int i=store;i<word1.size();i++)\n       {\n        if(j<word2.size() && word1[i]==word2[j])\n        {\n            ans.push_back(i);\n            j++;\n        }\n       }\n   \n   if(ans.size()==word2.size())\n   {\n    return ans;\n   }\n       \n       //wrna return empty vector\n       return {};\n    }\n};\n```
['C++']