[Java]  O(n) beats 99.41% concise solution HashMap with detailed explanation
Create  a  hash table to keep the counts of each substring and then calculate the ans by checking whether the susbtring before the partition and substring after
Create  a  hash table to keep the counts of each substring and then calculate the ans by checking whether the susbtring before the partition and substring after partition equal the target and both exist in the map with the partition passing linearly through the target. \n\n\n```\nclass Solution {\n    public int numOfPairs(String[] nums, String target) {\n        \n        HashMap<String, Integer> map = new HashMap<>();\n        for (int i = 0; i<nums.length; i++){\n            map.put(nums[i], map.getOrDefault(nums[i],0)+1);\n        }\n        \n        int ans = 0, n = target.length();\n        String a = "", b= "";\n        for (int i = 1; i<n; i++){\n            a = target.substring(0,i);\n            b = target.substring(i,n);\n            if (map.containsKey(a) && map.containsKey(b)){\n                if (a.equals(b)) ans += (map.get(a) * (map.get(a)-1));\n                else ans+= (map.get(a) * map.get(b));\n            }\n        }\n        return ans;\n    }\n}\n```\n
['Java']