You are viewing a single comment's thread. Return to all comments →
Not the desired approach but it gets the job done though
static void Main(String[] args) { string[] token=Console.ReadLine().Split(' '); int n=Convert.ToInt32(token[0]); int k=Convert.ToInt32(token[1]); string[] arr1=Console.ReadLine().Split(' '); int [] arr=Array.ConvertAll(arr1,int.Parse);
int temp=0; Queue<int> l=new Queue<int>(); for(int i=0;i<n;i++){ l.Enqueue(arr[i]); } for(int j=0;j<k;j++){ temp=l.Dequeue(); l.Enqueue(temp); } foreach(int i in l){ Console.Write("{0} ",i); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Left Rotation
You are viewing a single comment's thread. Return to all comments →
Not the desired approach but it gets the job done though
static void Main(String[] args) { string[] token=Console.ReadLine().Split(' '); int n=Convert.ToInt32(token[0]); int k=Convert.ToInt32(token[1]); string[] arr1=Console.ReadLine().Split(' '); int [] arr=Array.ConvertAll(arr1,int.Parse);