short solution


  • 0
    L
        void rotate(vector<int>& nums, int k) {
            int n = 0, m = nums.size()-1;
            while (k--){
                n = nums[m];
                nums.pop_back();
                nums.insert(nums.begin(),n);
            }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.