✅ Dictionary Prefix/Suffix Diff Approach
\n\n# Solution\nswift\nstruct Solution {\n    @_optimize(speed)\n    func numOfPairs(_ nums: [String], _ target: String) -> Int {\n        var concats = 0\n    
![Screenshot.png](https://assets.leetcode.com/users/images/113d283c-f709-4327-99f4-80180cd2d234_1713713844.2194514.png)\n\n# Solution\n```swift\nstruct Solution {\n    @_optimize(speed)\n    func numOfPairs(_ nums: [String], _ target: String) -> Int {\n        var concats = 0\n        // Store String.Subsequence instead of String to eliminate the need to repeatedly convert the suffix string in the for-in loop, as dropFirst returns String.Subsequence.\n        let freqs = Dictionary(nums.map { ($0[...], 1) }, uniquingKeysWith: +)\n        \n        for num in nums where target.prefix(num.count) == num {\n            let remaining = target.dropFirst(num.count)\n            concats += freqs[remaining] ?? 0\n            concats -= num == remaining ? 1 : 0\n        }\n        return concats\n    }\n}\n```
['Array', 'Hash Table', 'String', 'Swift', 'Counting']