LC.P1023[驼峰式匹配] 方法一:双指针123456789101112131415161718192021class Solution { public List<Boolean> camelMatch(String[] queries, String pattern) { List<Boolean> ans = new ArrayList<>(); int length = pattern.length(); for (String query : queries) { int n = query.length(), j = 0; boolean flag = true; for (int i = 0; i < n; ++i) { char c = query.charAt(i); if (j < length && pattern.charAt(j) == c) ++j; else if (Character.isUpperCase(c)) { flag = false; break; } } if (j != length) flag = false; ans.add(flag); } return ans; }} 时间复杂度:$O(mn)$,其中$n$为$queries$的长度,$m$为$queries[i]$的长度 空间复杂度:$O(1)$