Skip to content

Commit 944824d

Browse files
committed
Create README - LeetHub
1 parent b34e733 commit 944824d

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

rotate-array/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<h2>189. Rotate Array</h2><h3>Medium</h3><hr><div><p>Given an array, rotate the array to the right by <code>k</code> steps, where <code>k</code> is non-negative.</p>
2+
3+
<p>&nbsp;</p>
4+
<p><strong>Example 1:</strong></p>
5+
6+
<pre><strong>Input:</strong> nums = [1,2,3,4,5,6,7], k = 3
7+
<strong>Output:</strong> [5,6,7,1,2,3,4]
8+
<strong>Explanation:</strong>
9+
rotate 1 steps to the right: [7,1,2,3,4,5,6]
10+
rotate 2 steps to the right: [6,7,1,2,3,4,5]
11+
rotate 3 steps to the right: [5,6,7,1,2,3,4]
12+
</pre>
13+
14+
<p><strong>Example 2:</strong></p>
15+
16+
<pre><strong>Input:</strong> nums = [-1,-100,3,99], k = 2
17+
<strong>Output:</strong> [3,99,-1,-100]
18+
<strong>Explanation:</strong>
19+
rotate 1 steps to the right: [99,-1,-100,3]
20+
rotate 2 steps to the right: [3,99,-1,-100]
21+
</pre>
22+
23+
<p>&nbsp;</p>
24+
<p><strong>Constraints:</strong></p>
25+
26+
<ul>
27+
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
28+
<li><code>-2<sup>31</sup> &lt;= nums[i] &lt;= 2<sup>31</sup> - 1</code></li>
29+
<li><code>0 &lt;= k &lt;= 10<sup>5</sup></code></li>
30+
</ul>
31+
32+
<p>&nbsp;</p>
33+
<p><strong>Follow up:</strong></p>
34+
35+
<ul>
36+
<li>Try to come up with as many solutions as you can. There are at least <strong>three</strong> different ways to solve this problem.</li>
37+
<li>Could you do it in-place with <code>O(1)</code> extra space?</li>
38+
</ul>
39+
</div>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy