给你一个 数字 字符串数组 nums 和一个 数字 字符串 target ,请你返回 nums[i] + nums[j] (两个字符串连接)结果等于 target 的下标 (i, j) (需满足 i != j)的数目。
来源:力扣(LeetCode)
class Solution
{
public int numOfPairs(String[] nums, String target)
{
int ans = 0;
for (int i = 0; i < nums.length - 1; i ++)
{
for (int j = i + 1; j < nums.length; j ++)
{
// equals 比对是否相等
if (target.equals(nums[i] + nums[j]) == true)
{
ans ++;
}
if (target.equals(nums[j] + nums[i]) == true)
{
ans ++;
}
}
}
return ans;
}
}