C++||O(n)||EASY SOLUTION ||EASY explanation
Intuition\n Describe your first thoughts on how to solve this problem. \n ## Swaping number in array basically. please voteup \uD83D\uDE4F\uD83D\uDE4F\uD83D\uDE
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n ## Swaping number in array basically. please voteup \uD83D\uDE4F\uD83D\uDE4F\uD83D\uDE4F\t \n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. some people might be thinking why i am using k=k%n when k>n because there are only two possibility first is when k is divisible by \'n\' than no need to change-.. if it\'s not divisible than k%n time we have to run the loop.\n2. first you make a vector to copy the given array because if we changing  in array will affect the value of given array.That why we have to make a copy of given array.\n3. second start changing in array nums[i]value to last "num[n-k+i]--> which is 5 when i=0,6 -->i=1,...".run it only  k time.for shifting of array last to first\n4. Third loop will change remain position of array nuumber.basically for shifting of array.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    void rotate(vector<int>& nums, int k) {\n        vector<int>v;// making vector for copy the array in vector.\n        int n=nums.size();\n        if(k>nums.size()){\n           k=k%n;// check k>n and than check it is divisible by n or not.\n       }\n        for(int i=0;i<n;i++){\n           v.push_back(nums[i]);// puting nums value to vector..\n        }\n       for(int i=0;i<k;i++){\n           nums[i]=v[n-k+i];// puting value of vector into nums..i explained it above..\n        }\n        for(int i=0;i<n-k;i++){ \n            nums[k+i]=v[i];// here we will changing  all value (n-k time)of nums array after runing k time. for shifting of array.\n        }\n      return ;\n    }\n};// ;)plzz like bro..................................>>>>>>>>>>>>>>\n```
['C++']