Content-Length: 330974 | pFad | http://github.com/hajin-kim/algorithm-leetcode/commit/7cbfe4b536cb57fb7daaafd6a8180ca4a9702b8a

FD Create README - LeetHub · hajin-kim/algorithm-leetcode@7cbfe4b · GitHub
Skip to content

Commit 7cbfe4b

Browse files
committed
Create README - LeetHub
1 parent 197d77c commit 7cbfe4b

File tree

1 file changed

+43
-0
lines changed
  • 0167-two-sum-ii-input-array-is-sorted

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<h2><a href="https://leetcode.com/problems/two-sum-ii-input-array-is-sorted">167. Two Sum II - Input Array Is Sorted</a></h2><h3>Medium</h3><hr><p>Given a <strong>1-indexed</strong> array of integers <code>numbers</code> that is already <strong><em>sorted in non-decreasing order</em></strong>, find two numbers such that they add up to a specific <code>target</code> number. Let these two numbers be <code>numbers[index<sub>1</sub>]</code> and <code>numbers[index<sub>2</sub>]</code> where <code>1 &lt;= index<sub>1</sub> &lt; index<sub>2</sub> &lt;= numbers.length</code>.</p>
2+
3+
<p>Return<em> the indices of the two numbers, </em><code>index<sub>1</sub></code><em> and </em><code>index<sub>2</sub></code><em>, <strong>added by one</strong> as an integer array </em><code>[index<sub>1</sub>, index<sub>2</sub>]</code><em> of length 2.</em></p>
4+
5+
<p>The tests are generated such that there is <strong>exactly one solution</strong>. You <strong>may not</strong> use the same element twice.</p>
6+
7+
<p>Your solution must use only constant extra space.</p>
8+
9+
<p>&nbsp;</p>
10+
<p><strong class="example">Example 1:</strong></p>
11+
12+
<pre>
13+
<strong>Input:</strong> numbers = [<u>2</u>,<u>7</u>,11,15], target = 9
14+
<strong>Output:</strong> [1,2]
15+
<strong>Explanation:</strong> The sum of 2 and 7 is 9. Therefore, index<sub>1</sub> = 1, index<sub>2</sub> = 2. We return [1, 2].
16+
</pre>
17+
18+
<p><strong class="example">Example 2:</strong></p>
19+
20+
<pre>
21+
<strong>Input:</strong> numbers = [<u>2</u>,3,<u>4</u>], target = 6
22+
<strong>Output:</strong> [1,3]
23+
<strong>Explanation:</strong> The sum of 2 and 4 is 6. Therefore index<sub>1</sub> = 1, index<sub>2</sub> = 3. We return [1, 3].
24+
</pre>
25+
26+
<p><strong class="example">Example 3:</strong></p>
27+
28+
<pre>
29+
<strong>Input:</strong> numbers = [<u>-1</u>,<u>0</u>], target = -1
30+
<strong>Output:</strong> [1,2]
31+
<strong>Explanation:</strong> The sum of -1 and 0 is -1. Therefore index<sub>1</sub> = 1, index<sub>2</sub> = 2. We return [1, 2].
32+
</pre>
33+
34+
<p>&nbsp;</p>
35+
<p><strong>Constraints:</strong></p>
36+
37+
<ul>
38+
<li><code>2 &lt;= numbers.length &lt;= 3 * 10<sup>4</sup></code></li>
39+
<li><code>-1000 &lt;= numbers[i] &lt;= 1000</code></li>
40+
<li><code>numbers</code> is sorted in <strong>non-decreasing order</strong>.</li>
41+
<li><code>-1000 &lt;= target &lt;= 1000</code></li>
42+
<li>The tests are generated such that there is <strong>exactly one solution</strong>.</li>
43+
</ul>

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/hajin-kim/algorithm-leetcode/commit/7cbfe4b536cb57fb7daaafd6a8180ca4a9702b8a

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy