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.
List<Integer> a = new ArrayList<>();
List<Integer> indexesRemove = new ArrayList<>();
a.add(1);
a.add(2);
a.add(3);
a.add(4);
a.add(5);
int d = 2;
for(int i = 0; i < d; i++){
a.add(a.get(i));
indexesRemove.add(i);
}
indexesRemove
.forEach(p -> a.remove(0));
System.out.println(a.toString());
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Arrays: Left Rotation
You are viewing a single comment's thread. Return to all comments →
Simple java solution: