@@ -0,0 +1,1449 @@
+public class Solution %7B%0A  // rotate array by copying parts 0-k and k-(n-k)%0A  // O(n) time and O(n) space complexity%0A  public void rotate1(int%5B%5D nums, int k) %7B%0A    int n = nums.length;%0A    k = k %25 n;%0A    int%5B%5D res = new int%5Bn%5D;%0A    System.arraycopy(nums, 0, res, 0, n);%0A    System.arraycopy(res, n - k, nums, 0, k);%0A    System.arraycopy(res, 0, nums, k, n - k);%0A  %7D%0A%0A  // rotate array by storing array twice in single array,%0A  // then extracting from n - k to 2n - k and copying into original array%0A  // O(n) time and O(n) space complexity%0A  public void rotate2(int%5B%5D nums, int k) %7B%0A    int n = nums.length;%0A    k = k %25 n;%0A    int%5B%5D res = new int%5Bn * 2%5D;%0A    for (int i = 0; i %3C n; i++) %7B%0A      res%5Bi%5D = nums%5Bi%5D;%0A      res%5Bi + n%5D = nums%5Bi%5D;%0A    %7D%0A%0A    int j = 0;%0A    for (int i = n - k; i %3C 2 * n - k; i++) %7B%0A      nums%5Bj++%5D = res%5Bi%5D;%0A    %7D%0A  %7D%0A%0A  // rotate array by reversing it; first, reverse entire array, second, reverse 0-k part and%0A  // then reverse k - (n - 1) part, e.g.%0A  // %5B1, 2, 3, 4, 5%5D, k = 2 =%3E %5B5, 4, 3, 2, 1%5D =%3E %5B4, 5, 3, 2, 1%5D =%3E %5B4, 5, 1, 2, 3%5D%0A  private void reverse(int%5B%5D nums, int start, int end) %7B%0A    while (start %3C end) %7B%0A      int tmp = nums%5Bstart%5D;%0A      nums%5Bstart%5D = nums%5Bend%5D;%0A      nums%5Bend%5D = tmp;%0A      start++;%0A      end--;%0A    %7D%0A  %7D%0A%0A  public void rotate(int%5B%5D nums, int k) %7B%0A    k = k %25 nums.length;%0A    reverse(nums, 0, nums.length - 1);%0A    reverse(nums, 0, k - 1);%0A    reverse(nums, k, nums.length - 1);%0A  %7D%0A%7D%0A

add rotate-array solution