Class Solution
java.lang.Object
g2001_2100.s2023_number_of_pairs_of_strings_with_concatenation_equal_to_target.Solution
2023 - Number of Pairs of Strings With Concatenation Equal to Target.<p>Medium</p>
<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><strong>Example 1:</strong></p>
<p><strong>Input:</strong> nums = [“777”,“7”,“77”,“77”], target = “7777”</p>
<p><strong>Output:</strong> 4</p>
<p><strong>Explanation:</strong> Valid pairs are:</p>
<ul>
<li>
<p>(0, 1): “777” + “7”</p>
</li>
<li>
<p>(1, 0): “7” + “777”</p>
</li>
<li>
<p>(2, 3): “77” + “77”</p>
</li>
<li>
<p>(3, 2): “77” + “77”</p>
</li>
</ul>
<p><strong>Example 2:</strong></p>
<p><strong>Input:</strong> nums = [“123”,“4”,“12”,“34”], target = “1234”</p>
<p><strong>Output:</strong> 2</p>
<p><strong>Explanation:</strong> Valid pairs are:</p>
<ul>
<li>
<p>(0, 1): “123” + “4”</p>
</li>
<li>
<p>(2, 3): “12” + “34”</p>
</li>
</ul>
<p><strong>Example 3:</strong></p>
<p><strong>Input:</strong> nums = [“1”,“1”,“1”], target = “11”</p>
<p><strong>Output:</strong> 6</p>
<p><strong>Explanation:</strong> Valid pairs are:</p>
<ul>
<li>
<p>(0, 1): “1” + “1”</p>
</li>
<li>
<p>(1, 0): “1” + “1”</p>
</li>
<li>
<p>(0, 2): “1” + “1”</p>
</li>
<li>
<p>(2, 0): “1” + “1”</p>
</li>
<li>
<p>(1, 2): “1” + “1”</p>
</li>
<li>
<p>(2, 1): “1” + “1”</p>
</li>
</ul>
<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>
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Solution
public Solution()
-
-
Method Details
-
numOfPairs
-