Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amit MohantyRank #112 · 20K reputationPosted Nov 1, 2022, 2:47 AM EDT
Check this
int[] array = new int[] { 1, 2, 3, 4, 5, 6, 7 }; int rotation = 3; //from which position you want to rotate int[] newArray = new int[array.Length]; for (int i = rotation; i <= (array.Length - 1); i++) { newArray[i - rotation] = array[i]; } for (int i = 0; i < rotation; i++) { newArray[(array.Length + i) - rotation] = array[i]; } //To check rotation of array for (int i = 0; i < newArray.Length; i++) { Console.Write(newArray[i] + " "); }Sachin SinghRank #66 · 26.2K reputationPosted Nov 1, 2022, 2:27 AM EDT
Please follow this
https://www.geeksforgeeks.org/array-rotation/
Brahma Prakash ShuklaRank #633 · 3.8K reputationPosted Nov 4, 2022, 9:42 AM EDT