Skip to content

Commit bc825a9

Browse files
Create README - LeetHub
1 parent ddb8566 commit bc825a9

File tree

1 file changed

+37
-0
lines changed
  • 0581-shortest-unsorted-continuous-subarray

1 file changed

+37
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<h2><a href="https://leetcode.com/problems/shortest-unsorted-continuous-subarray">581. Shortest Unsorted Continuous Subarray</a></h2><h3>Medium</h3><hr><p>Given an integer array <code>nums</code>, you need to find one <b>continuous subarray</b> such that if you only sort this subarray in non-decreasing order, then the whole array will be sorted in non-decreasing order.</p>
2+
3+
<p>Return <em>the shortest such subarray and output its length</em>.</p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong class="example">Example 1:</strong></p>
7+
8+
<pre>
9+
<strong>Input:</strong> nums = [2,6,4,8,10,9,15]
10+
<strong>Output:</strong> 5
11+
<strong>Explanation:</strong> You need to sort [6, 4, 8, 10, 9] in ascending order to make the whole array sorted in ascending order.
12+
</pre>
13+
14+
<p><strong class="example">Example 2:</strong></p>
15+
16+
<pre>
17+
<strong>Input:</strong> nums = [1,2,3,4]
18+
<strong>Output:</strong> 0
19+
</pre>
20+
21+
<p><strong class="example">Example 3:</strong></p>
22+
23+
<pre>
24+
<strong>Input:</strong> nums = [1]
25+
<strong>Output:</strong> 0
26+
</pre>
27+
28+
<p>&nbsp;</p>
29+
<p><strong>Constraints:</strong></p>
30+
31+
<ul>
32+
<li><code>1 &lt;= nums.length &lt;= 10<sup>4</sup></code></li>
33+
<li><code>-10<sup>5</sup> &lt;= nums[i] &lt;= 10<sup>5</sup></code></li>
34+
</ul>
35+
36+
<p>&nbsp;</p>
37+
<strong>Follow up:</strong> Can you solve it in <code>O(n)</code> time complexity?

0 commit comments

Comments
 (0)