Skip to content

Commit b0bcf65

Browse files
committed
Create README - LeetHub
1 parent 2e73b2a commit b0bcf65

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

0228-summary-ranges/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<h2><a href="https://leetcode.com/problems/summary-ranges/">228. Summary Ranges</a></h2><h3>Easy</h3><hr><div><p>You are given a <strong>sorted unique</strong> integer array <code>nums</code>.</p>
2+
3+
<p>A <strong>range</strong> <code>[a,b]</code> is the set of all integers from <code>a</code> to <code>b</code> (inclusive).</p>
4+
5+
<p>Return <em>the <strong>smallest sorted</strong> list of ranges that <strong>cover all the numbers in the array exactly</strong></em>. That is, each element of <code>nums</code> is covered by exactly one of the ranges, and there is no integer <code>x</code> such that <code>x</code> is in one of the ranges but not in <code>nums</code>.</p>
6+
7+
<p>Each range <code>[a,b]</code> in the list should be output as:</p>
8+
9+
<ul>
10+
<li><code>"a-&gt;b"</code> if <code>a != b</code></li>
11+
<li><code>"a"</code> if <code>a == b</code></li>
12+
</ul>
13+
14+
<p>&nbsp;</p>
15+
<p><strong class="example">Example 1:</strong></p>
16+
17+
<pre><strong>Input:</strong> nums = [0,1,2,4,5,7]
18+
<strong>Output:</strong> ["0-&gt;2","4-&gt;5","7"]
19+
<strong>Explanation:</strong> The ranges are:
20+
[0,2] --&gt; "0-&gt;2"
21+
[4,5] --&gt; "4-&gt;5"
22+
[7,7] --&gt; "7"
23+
</pre>
24+
25+
<p><strong class="example">Example 2:</strong></p>
26+
27+
<pre><strong>Input:</strong> nums = [0,2,3,4,6,8,9]
28+
<strong>Output:</strong> ["0","2-&gt;4","6","8-&gt;9"]
29+
<strong>Explanation:</strong> The ranges are:
30+
[0,0] --&gt; "0"
31+
[2,4] --&gt; "2-&gt;4"
32+
[6,6] --&gt; "6"
33+
[8,9] --&gt; "8-&gt;9"
34+
</pre>
35+
36+
<p>&nbsp;</p>
37+
<p><strong>Constraints:</strong></p>
38+
39+
<ul>
40+
<li><code>0 &lt;= nums.length &lt;= 20</code></li>
41+
<li><code>-2<sup>31</sup> &lt;= nums[i] &lt;= 2<sup>31</sup> - 1</code></li>
42+
<li>All the values of <code>nums</code> are <strong>unique</strong>.</li>
43+
<li><code>nums</code> is sorted in ascending order.</li>
44+
</ul>
45+
</div>

0 commit comments

Comments
 (0)