Given an array of digit strings nums and a digit string target, return the number of pairs of indices (i, j) (where i != j) such that the concatenation of nums[i] + nums[j] equals target.

&nbsp;
Example 1:

Input: nums = ["777","7","77","77"], target = "7777"
Output: 4
Explanation: Valid pairs are:
- (0, 1): "777" + "7"
- (1, 0): "7" + "777"
- (2, 3): "77" + "77"
- (3, 2): "77" + "77"


Example 2:

Input: nums = ["123","4","12","34"], target = "1234"
Output: 2
Explanation: Valid pairs are:
- (0, 1): "123" + "4"
- (2, 3): "12" + "34"


Example 3:

Input: nums = ["1","1","1"], target = "11"
Output: 6
Explanation: Valid pairs are:
- (0, 1): "1" + "1"
- (1, 0): "1" + "1"
- (0, 2): "1" + "1"
- (2, 0): "1" + "1"
- (1, 2): "1" + "1"
- (2, 1): "1" + "1"


&nbsp;
Constraints:


	2 &lt;= nums.length &lt;= 100
	1 &lt;= nums[i].length &lt;= 100
	2 &lt;= target.length &lt;= 100
	nums[i] and target consist of digits.
	nums[i] and target do not have leading zeros.


class Solution:
    def numOfPairs(self, nums, target):
        return sum(i + j == target for i, j in permutations(nums, 2))
class Solution {
    public int numOfPairs(String[] nums, String target) {
        
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i<nums.length; i++){
            map.put(nums[i], map.getOrDefault(nums[i],0)+1);
        }
        
        int ans = 0, n = target.length();
        String a = "", b= "";
        for (int i = 1; i<n; i++){
            a = target.substring(0,i);
            b = target.substring(i,n);
            if (map.containsKey(a) && map.containsKey(b)){
                if (a.equals(b)) ans += (map.get(a) * (map.get(a)-1));
                else ans+= (map.get(a) * map.get(b));
            }
        }
        return ans;
    }
}
class Solution {
public:
    int numOfPairs(vector<string>& nums, string target) {
        unordered_map<string, int> freq;
        for (auto num : nums) if (num.size() < target.size()) freq[num]++;
        
        int res = 0;
        for (auto [s, frq] : freq) {
            
            if (target.find(s) == 0) {
                
                if (s + s == target) 
                    res += frq*(frq-1);
                
                else 
                    res += frq * freq[target.substr(s.size())];
            }
        }
        
        return res;
    }
};
/**
 * @param {string[]} nums
 * @param {string} target
 * @return {number}
 */
var numOfPairs = function(nums, target) {
    var count = 0;
    var x = 0;
    while (x < nums.length) {
        for (let y = 0; y<nums.length; y++) {
            if (nums[x] + nums[y] == target) {
                count += 1;
                if (x == y) {
                    count -= 1;
                }
            }
        }
        x++;
    }
    return count;
};
Number of Pairs of Strings With Concatenation Equal to Target