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.
publicstaticList<Integer>circularArrayRotation(List<Integer>a,intk,List<Integer>queries){// Write your code here// Converted List to Arrayint[]answer=a.stream().mapToInt(i->i).toArray();// Right Rotation of listwhile(k>0){intfirst=answer[answer.length-1];for(inti=answer.length-1;i>0;i--){answer[i]=answer[i-1];}answer[0]=first;k--;}List<Integer>list=newArrayList<>();for(inti=0;i<queries.size();i++){list.add(answer[queries.get(i)]);}returnlist;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Circular Array Rotation
You are viewing a single comment's thread. Return to all comments →