Easy  Suffix Approach  Java🔥🚀🚀
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\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```java []\nclass Solution {\n    public int[] validSequence(String word1, String word2) {\n        int suffix[]=new int[word1.length()+1]; \n        int n=word1.length();\n        int m=word2.length();\n         int l=n-1;\n         int r=m-1;\n         suffix[n]=0;\n  \n    while(l>=0){\n        if( r>=0 && word1.charAt(l)==word2.charAt(r) ){\n            suffix[l]=suffix[l+1] + 1;\n            r--;\n        }\n        else{\n            suffix[l]=suffix[l+1];\n        }\n        l--;\n    }\n\n\n            int ans[]=new int[m];\n            l=0;\n            r=0;\n            int f=0;\n            while( r < m && l<n ){\n                if(word1.charAt(l)==word2.charAt(r)){\n                    ans[r]=l;\n                    r++;\n                    l++;\n                }\n                else{\n                     int remainingLength=(m-r-1);\n                     if( suffix[l+1]>= remainingLength && f==0){\n                         ans[r]=l;\n                         r++;\n                         f=1;\n                     }\n\n                    l++;\n                }\n\n            }\n\n            if(r<m){\n                return new int[0];\n            }\n            return ans;\n        \n        \n        \n    }\n}\n```
['Two Pointers', 'Suffix Array', 'Java']