You are viewing a single comment's thread. Return to all comments →
import java.io.*; import java.util.stream.Stream; public class ArrayLeftRotation { public static void main(String[] args) throws IOException { try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out))) { int[] firstLine = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); int n = firstLine[0]; int d = firstLine[1]; int[] array = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); for (int i = 0; i < n; i++) { bw.write(array[(i + d) % n] + " "); } bw.newLine(); bw.flush(); } catch (IOException e) { throw new RuntimeException(e); } } }
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 →