标签:旋转数组 end reverse bsp size eve rev cto amp
1 class Solution 2 { 3 public: 4 void rotate(vector<int>& nums, int k) 5 { 6 int n = nums.size(); 7 k = k % n; 8 reverse(nums.begin(),nums.begin() + n - k); 9 reverse(nums.begin() + n - k,nums.end()); 10 reverse(nums.begin(),nums.end()); 11 } 12 };
标签:旋转数组 end reverse bsp size eve rev cto amp
原文地址:https://www.cnblogs.com/yuhong1103/p/12629466.html