mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
50 lines
1.9 KiB
HTML
50 lines
1.9 KiB
HTML
<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>
|
|
<p><strong>Example 1:</strong></p>
|
|
|
|
<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>
|
|
|
|
<p><strong>Example 2:</strong></p>
|
|
|
|
<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>
|
|
|
|
<p><strong>Example 3:</strong></p>
|
|
|
|
<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>
|