Given an array, rotate the array to the right by k steps, where k is non-negative.
Example 1:
1 | Input: nums = [1,2,3,4,5,6,7], k = 3 |
Example 2:
1 | Input: nums = [-1,-100,3,99], k = 2 |
三次反轉。
1 | TC: O(n), SC: O(1) |
如果你覺得這篇文章很棒,請你不吝點讚 (゚∀゚)
Given an array, rotate the array to the right by k steps, where k is non-negative.
Example 1:
1 | Input: nums = [1,2,3,4,5,6,7], k = 3 |
Example 2:
1 | Input: nums = [-1,-100,3,99], k = 2 |
三次反轉。
1 | TC: O(n), SC: O(1) |
如果你覺得這篇文章很棒,請你不吝點讚 (゚∀゚)
Welcome to my other publishing channels