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.
public static List<Integer> rotateLeft(int d, List<Integer> arr) {
//maybe it might be an unnecessarily long solution
Queue<Integer> q = new LinkedList<>();
List<Integer> list = new ArrayList<>();
for(int arrItem : arr){
q.add(arrItem);
}
for(int i = 0; i < d; i++){
int temp = q.remove();
q.add(temp);
}
for(int i = 0; i < arr.size(); i++ ){
list.add(q.element());
q.remove();
}
return list;
}
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 →