We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
did you ever figure it out? I'm having the same problem in JS
functionmain(){varn_temp=readLine().split(' ');varn=parseInt(n_temp[0]);vark=parseInt(n_temp[1]);a=readLine().split(' ');a=a.map(Number);//console.log("n is "+n);//console.log("k is "+k);//console.log("a is "+a);varlength=n;vararr=a;varnewArr=[];varvalue;varindex;for(vari=0;i<length;i++){value=arr[i];index=i;for(varv=0;v<k;v++){index=(index-1);if(index==-1){index=length-1;if(v==(k-1)){newArr[index]=value;}}elseif(v==(k-1)){newArr[index]=value;}}}console.log(newArr.join(" "));}
Cookie support is required to access HackerRank
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 →
did you ever figure it out? I'm having the same problem in JS