mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
72 lines
2.4 KiB
HTML
72 lines
2.4 KiB
HTML
<p>You are given two arrays of equal length, <code>nums1</code> and <code>nums2</code>.</p>
|
|
|
|
<p>Each element in <code>nums1</code> has been increased (or decreased in the case of negative) by an integer, represented by the variable <code>x</code>.</p>
|
|
|
|
<p>As a result, <code>nums1</code> becomes <strong>equal</strong> to <code>nums2</code>. Two arrays are considered <strong>equal</strong> when they contain the same integers with the same frequencies.</p>
|
|
|
|
<p>Return the integer <code>x</code>.</p>
|
|
|
|
<p> </p>
|
|
<p><strong class="example">Example 1:</strong></p>
|
|
|
|
<div class="example-block">
|
|
<p><strong>Input:</strong> <span class="example-io" style="
|
|
font-family: Menlo,sans-serif;
|
|
font-size: 0.85rem;
|
|
">nums1 = [2,6,4], nums2 = [9,7,5]</span></p>
|
|
|
|
<p><strong>Output:</strong> <span class="example-io" style="
|
|
font-family: Menlo,sans-serif;
|
|
font-size: 0.85rem;
|
|
">3</span></p>
|
|
|
|
<p><strong>Explanation:</strong></p>
|
|
|
|
<p>The integer added to each element of <code>nums1</code> is 3.</p>
|
|
</div>
|
|
|
|
<p><strong class="example">Example 2:</strong></p>
|
|
|
|
<div class="example-block">
|
|
<p><strong>Input:</strong> <span class="example-io" style="
|
|
font-family: Menlo,sans-serif;
|
|
font-size: 0.85rem;
|
|
">nums1 = [10], nums2 = [5]</span></p>
|
|
|
|
<p><strong>Output:</strong> <span class="example-io" style="
|
|
font-family: Menlo,sans-serif;
|
|
font-size: 0.85rem;
|
|
">-5</span></p>
|
|
|
|
<p><strong>Explanation:</strong></p>
|
|
|
|
<p>The integer added to each element of <code>nums1</code> is -5.</p>
|
|
</div>
|
|
|
|
<p><strong class="example">Example 3:</strong></p>
|
|
|
|
<div class="example-block">
|
|
<p><strong>Input:</strong> <span class="example-io" style="
|
|
font-family: Menlo,sans-serif;
|
|
font-size: 0.85rem;
|
|
">nums1 = [1,1,1,1], nums2 = [1,1,1,1]</span></p>
|
|
|
|
<p><strong>Output:</strong> <span class="example-io" style="
|
|
font-family: Menlo,sans-serif;
|
|
font-size: 0.85rem;
|
|
">0</span></p>
|
|
|
|
<p><strong>Explanation:</strong></p>
|
|
|
|
<p>The integer added to each element of <code>nums1</code> is 0.</p>
|
|
</div>
|
|
|
|
<p> </p>
|
|
<p><strong>Constraints:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>1 <= nums1.length == nums2.length <= 100</code></li>
|
|
<li><code>0 <= nums1[i], nums2[i] <= 1000</code></li>
|
|
<li>The test cases are generated in a way that there is an integer <code>x</code> such that <code>nums1</code> can become equal to <code>nums2</code> by adding <code>x</code> to each element of <code>nums1</code>.</li>
|
|
</ul>
|