2023. Number of Pairs of Strings With Concatenation Equal to Target
Содержание
class Solution:
def numOfPairs(self, nums: List[str], target: str) -> int:
cnt = Counter(nums)
res = 0
for i in range(1, len(target)):
a, b = target[:i], target[i:]
if a != b:
res += cnt[a] * cnt[b]
else:
res += cnt[a] * (cnt[a] - 1)
return res