Given an array of strings queries and a string pattern, return a boolean array answer where answer[i] is true if queries[i] matches pattern, and false otherwise.

A query word queries[i] matches pattern if you can insert lowercase English letters pattern so that it equals the query. You may insert each character at any position and you may not insert any characters.

&nbsp;
Example 1:

Input: queries = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], pattern = "FB"
Output: [true,false,true,true,false]
Explanation: "FooBar" can be generated like this "F" + "oo" + "B" + "ar".
"FootBall" can be generated like this "F" + "oot" + "B" + "all".
"FrameBuffer" can be generated like this "F" + "rame" + "B" + "uffer".


Example 2:

Input: queries = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], pattern = "FoBa"
Output: [true,false,true,false,false]
Explanation: "FooBar" can be generated like this "Fo" + "o" + "Ba" + "r".
"FootBall" can be generated like this "Fo" + "ot" + "Ba" + "ll".


Example 3:

Input: queries = ["FooBar","FooBarTest","FootBall","FrameBuffer","ForceFeedBack"], pattern = "FoBaT"
Output: [false,true,false,false,false]
Explanation: "FooBarTest" can be generated like this "Fo" + "o" + "Ba" + "r" + "T" + "est".


&nbsp;
Constraints:


	1 &lt;= pattern.length, queries.length &lt;= 100
	1 &lt;= queries[i].length &lt;= 100
	queries[i] and pattern consist of English letters.


class Solution:
    def camelMatch(self, queries: List[str], pattern: str) -> List[bool]:
        res, N = [], len(pattern)
		
        for query in queries:
		
            if self.upLetter(query) != self.upLetter(pattern) or self.LCS(query, pattern) != N:
                res.append(False)
            
            else:
                res.append(True)
				
        return res
                
        
		
    def LCS(self, A, B):
        N, M = len(A), len(B)
        d = [[0 for _ in range(M+1)] for _ in range(N+1)]

        for i in range(1, N+1):
            for j in range(1, M+1):
			
                if A[i - 1] == B[j - 1]:
                    d[i][j] = 1 + d[i-1][j-1]

                else:
                    d[i][j] = max(d[i-1][j], d[i][j-1])
        return d[-1][-1]


    
    def upLetter(self, w):
        count = 0
        for c in w:
            if c.isupper():
                count += 1
        return count
class Solution {
    public List<Boolean> camelMatch(String[] queries, String pattern) {
      List<Boolean> list = new ArrayList<>();

      for (var q : queries) {
         int index = 0;
         boolean flag = true;
         for (var c : q.toCharArray()) {
            if(index < pattern.length() && c == pattern.charAt(index)){
               index++;
               continue;
            }
            if(c >= 'A' && c <= 'Z'){
               if(index >= pattern.length() || c != pattern.charAt(index)){
                  flag = false;
                  break;
               }
            }
         }
         flag = flag && index == pattern.length();
         list.add(flag);
      }
      return list;
    }
}
class Solution {
public:
    vector<bool> camelMatch(vector<string>& queries, string pattern) {
        
        vector<bool> res(queries.size());
        
        for (int i = 0; i < queries.size(); i++)
        {
            int patRef = 0;
            bool isCamel = true;
            
            for (const char& ltr : queries[i])
            {
                if (patRef == pattern.size())
                {
                    if (isupper(ltr))
                    {
                        isCamel = false;
                        break;
                    }
                }
                else
                {
                    if (isupper(ltr) and isupper(pattern[patRef]) and ltr != pattern[patRef])
                    {
                        isCamel = false;
                        break;
                    }
                    else if (islower(ltr) and islower(pattern[patRef]) and ltr == pattern[patRef])
                        patRef++;
                    else if (ltr == pattern[patRef])
                        patRef++;
                }
            }
            
            if (patRef == pattern.size() and isCamel)
                res[i] = true;
        }
                             
        return res;
    }
};
var camelMatch = function(queries, pattern) {
    function camelMatch(q, p){
        let qlist=[]
        let plist=[]
        for(let a of q) if(a<='Z') qlist.push(a);
        for(let a of p) if(a<='Z') plist.push(a);
        return plist.join('') === qlist.join('')
    }
    function seqMatch(q, p){
        if(!camelMatch(p,q)) return false
        let pi=0
        for(let qi=0; qi<q.length; qi++){
            if(pi<p.length && p[pi]===q[qi]) pi++
        }
        return pi===p.length
    }

    return queries.map(q=>seqMatch(q, pattern))
}
Camelcase Matching