Easy Java Solution using HashMap faster than 99%
Approach:\n//the logic is similar to the two sum problem \n//first lets say we count the freq of each value of given array\n//iterate on the given array and fin
Approach:\n**//the logic is similar to the two sum problem \n//first lets say we count the freq of each value of given array\n//iterate on the given array and find out if that string is present as a prefix or not if it is present then just find if remaining suffix is present if yes increase count by number of suffix present \n//just a corner case in above logic if the prefix and suffix are same then while count we need to decrease freq by 1 ie for excluding self frquency for forming target eg case target="11" ar=[1,1,1]**\n```\nclass Solution {\n    public int numOfPairs(String[] nums, String target) {\n        HashMap<String,Integer>h=new HashMap<String,Integer>();\n    int ans=0;\n     for(int i=0;i<nums.length;i++){\n    \th.put(nums[i],h.getOrDefault(nums[i], 0)+1);\n    }\n    for(int i=0;i<nums.length;i++){\n        if(target.startsWith(nums[i])&&h.containsKey(target.substring(nums[i].length()))) {\n           if(nums[i].equals(target.substring(nums[i].length()))){\n               ans+=h.get(target.substring(nums[i].length()))-1;\n           }\n           else\n            ans+=h.get(target.substring(nums[i].length()));\n        }       \n    }\n    return ans;\n    }\n}``\n```
[]