Java o(n) using Map
\npublic int numOfPairs(String[] nums, String target) {\n\tMap<Integer, Integer> prefixMap = new HashMap<>(), suffixMap = new HashMap<>();\n\tint result = 0, n 
```\npublic int numOfPairs(String[] nums, String target) {\n\tMap<Integer, Integer> prefixMap = new HashMap<>(), suffixMap = new HashMap<>();\n\tint result = 0, n = target.length();\n\tfor(String num: nums)\n\t\tif(num.length() < n) {\n\t\t\tboolean isPrefix = target.indexOf(num)==0, isSufix = target.lastIndexOf(num)==n-num.length();\n\t\t\tif(isPrefix) result += suffixMap.getOrDefault(num.length(), 0);\n\t\t\tif(isSufix) result += prefixMap.getOrDefault(target.length()-num.length() - 1, 0);\n\t\t\tif(isPrefix) prefixMap.put(num.length()-1, prefixMap.getOrDefault(num.length()-1, 0) + 1);\n\t\t\tif(isSufix) suffixMap.put(n-num.length(), suffixMap.getOrDefault(n-num.length(), 0) + 1);\n\t\t}\n\treturn result;\n}\n```
[]