Rotate Left K Cells

[Solved] Rotate Left K Cells | Swift - Code Explorer | yomemimo.com
Question : Rotate Left k cells

Answered by : shakib

public static int [] rotateLeft(int [] source, int k){ int arr[] = copyArray(source, source.length); int[] temp = new int[arr.length]; for (int i=0; i<arr.length; i++) { temp[i] = arr[(i + k) % arr.length]; } for (int i=0; i<arr.length; i++) { arr[i] = temp[i]; } return arr;
}

Source : https://stackoverflow.com/questions/41922011/rotating-all-elements-of-the-array-to-left-by-k-position-but-my-code-moves-it | Last Update : Sat, 10 Jul 21

Answers related to rotate left k cells

Code Explorer Popular Question For Swift