2022-03-27 20:38:29 +08:00
< p > Given an array of < strong > digit< / strong > strings < code > nums< / code > and a < strong > digit< / strong > string < code > target< / code > , return < em > the number of pairs of indices < / em > < code > (i, j)< / code > < em > (where < / em > < code > i != j< / code > < em > ) such that the < strong > concatenation< / strong > of < / em > < code > nums[i] + nums[j]< / code > < em > equals < / em > < code > target< / code > .< / p >
< p > < / p >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 1:< / strong > < / p >
2022-03-27 20:38:29 +08:00
< pre >
< strong > Input:< / strong > nums = [" 777" ," 7" ," 77" ," 77" ], target = " 7777"
< strong > Output:< / strong > 4
< strong > Explanation:< / strong > Valid pairs are:
- (0, 1): " 777" + " 7"
- (1, 0): " 7" + " 777"
- (2, 3): " 77" + " 77"
- (3, 2): " 77" + " 77"
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 2:< / strong > < / p >
2022-03-27 20:38:29 +08:00
< pre >
< strong > Input:< / strong > nums = [" 123" ," 4" ," 12" ," 34" ], target = " 1234"
< strong > Output:< / strong > 2
< strong > Explanation:< / strong > Valid pairs are:
- (0, 1): " 123" + " 4"
- (2, 3): " 12" + " 34"
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 3:< / strong > < / p >
2022-03-27 20:38:29 +08:00
< pre >
< strong > Input:< / strong > nums = [" 1" ," 1" ," 1" ], target = " 11"
< strong > Output:< / strong > 6
< strong > Explanation:< / strong > 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"
< / pre >
< p > < / p >
< p > < strong > Constraints:< / strong > < / p >
< ul >
< li > < code > 2 < = nums.length < = 100< / code > < / li >
< li > < code > 1 < = nums[i].length < = 100< / code > < / li >
< li > < code > 2 < = target.length < = 100< / code > < / li >
< li > < code > nums[i]< / code > and < code > target< / code > consist of digits.< / li >
< li > < code > nums[i]< / code > and < code > target< / code > do not have leading zeros.< / li >
< / ul >