Java | O(n) | Frequency Map
Just track the frequency of each num in a HashMap. Then iterate over the array, for each num if target starts with that num check for the frequncy of the suffix
Just track the frequency of each ```num``` in a HashMap. Then iterate over the array, for each ```num``` if ```target``` starts with that ```num``` check for the frequncy of the suffix (remaining part) in the map. Take care of the case where ```num``` itself is also the suffix.\n\n```\nclass Solution {\n    public int numOfPairs(String[] nums, String target) {\n        int cnt=0;\n        HashMap<String, Integer> frq=new HashMap();\n        \n        for(String num:nums){\n            frq.put(num, frq.getOrDefault(num, 0)+1);\n        }\n        \n        for(String num:nums){\n            if(target.startsWith(num)){\n                String suf=target.substring(num.length());\n                if(frq.containsKey(suf)){\n                    cnt+=frq.get(suf)-(num.equals(suf)? 1:0);\n                }\n            }\n        }\n        return cnt;\n        \n    }\n}\n```
['Java']