LeetCode Rotate Array
If you use ArrayList instead of int[] you can write rotate2 like this (it's less efficient):

  public static List&lt;Integer&gt; rotate2(List&lt;Integer&gt; numsList, int k) {
    k = k % numsList.size();
    List&lt;Integer&gt; firstPart = numsList.subList(0, numsList.size() - k);
    List&lt;Integer&gt; secondPart = numsList.subList(numsList.size() - k, numsList.size());
    Collections.reverse(firstPart);
    Collections.reverse(secondPart);

    ArrayList&lt;Integer&gt; rotated = new ArrayList&lt;&gt;();
    rotated.addAll(firstPart);
    rotated.addAll(secondPart);

    return rotated;
  }


The arrayRotate1 can also be written this way, I don't know whether it's more readable or not but it's definitely less efficient:

  public static void rotate(int[] nums, int k) {
    k = k % nums.length;
    Queue&lt;Integer&gt; queue = new ArrayDeque&lt;&gt;(k);
    for (int i = 0; i &lt; Math.min(k, nums.length); i++) queue.add(nums[i]);
    for (int i = 0; i &lt; nums.length; i++) {
      int index = (i + k) % nums.length;
      queue.add(nums[index]);
      nums[index] = queue.remove();
    }
  }