title: How to shift the array elements by n-times?
body: <p>I have an array and I would like to shift the array elements by n-indexes. For simplicity of the problem, let's say, I would like to shift by <code>1-index</code> and then, I can write a <code>while</code> or <code>recursion</code> to make it <code>n-times</code>. </p>
  
  <p>Say,  the array is <code>A = [3, 8, 9, 7, 6]</code> and I would like to <code>right shift</code> by <code>1-index</code> to make it  <code>A = [6, 3, 8, 9, 7]</code></p>
  
  <p>I think of an HashMap that will take indexes and will shift by n-indexes. Say, </p>
  
  <pre><code>Map&lt;Integer, Integer&gt; map = new HashMap&lt;&gt;();
  int n = 2;
  
  for(int j =0; j &lt; arr.length; j++){
       if(j+2 &gt; arr.length -1){
           map.put(j+2 - arr.length, arr[j]);
       }
       map.put(j+2, arr[j]);
  }
  
  for(Map.Entry&lt;Integer, Integer&gt; map : amp.entrySet()){
       arr[map.getKey()] = map.getValue();
  }
  </code></pre>
  
  <p>The solution doesn't feel very good to me. How to write the algorithm for it ? </p>