|
4 | 4 |
|
5 | 5 | /**
|
6 | 6 | * Level: Easy
|
7 |
| - * Problem: https://leetcode.com/problems/rotate-array/ |
| 7 | + * Link: https://leetcode.com/problems/rotate-array/ |
| 8 | + * Description: |
| 9 | + * Given an array, rotate the array to the right by k steps, where k is non-negative. |
| 10 | + * |
| 11 | + * Example 1: |
| 12 | + * Input: [1,2,3,4,5,6,7] and k = 3 |
| 13 | + * Output: [5,6,7,1,2,3,4] |
| 14 | + * Explanation: |
| 15 | + * rotate 1 steps to the right: [7,1,2,3,4,5,6] |
| 16 | + * rotate 2 steps to the right: [6,7,1,2,3,4,5] |
| 17 | + * rotate 3 steps to the right: [5,6,7,1,2,3,4] |
| 18 | + * |
| 19 | + * Example 2: |
| 20 | + * Input: [-1,-100,3,99] and k = 2 |
| 21 | + * Output: [3,99,-1,-100] |
| 22 | + * Explanation: |
| 23 | + * rotate 1 steps to the right: [99,-1,-100,3] |
| 24 | + * rotate 2 steps to the right: [3,99,-1,-100] |
| 25 | + * |
| 26 | + * Note: |
| 27 | + * Try to come up as many solutions as you can, there are at least 3 different ways to solve this problem. |
| 28 | + * Could you do it in-place with O(1) extra space? |
8 | 29 | *
|
9 | 30 | * @author rampatra
|
10 | 31 | * @since 2019-04-20
|
|
0 commit comments