How to efficiently rotate an array?
<p>Given an array of <code>n</code> integers and a number, <code>d</code>, perform  left rotations on the array. Then print the updated array as a single line of space-separated integers.</p>

<p><strong>Sample Input:</strong></p>

<blockquote>
  <p>5 4<br>
  1 2 3 4 5</p>
</blockquote>

<p>The first line contains two space-separated integers denoting the respective values of <code>n</code> (the number of integers) and <code>d</code> (the number of left rotations you must perform). 
The second line contains <code>n</code> space-separated integers describing the respective elements of the array's initial state.</p>

<p><strong>Sample Output:</strong></p>

<blockquote>
  <p>5 1 2 3 4</p>
</blockquote>

<pre><code>static void Main(String[] args)
{
    string[] arr_temp = Console.ReadLine().Split(' ');
    int n = Int32.Parse(arr_temp[0]);
    int d = Int32.Parse(arr_temp[1]);

    string[] arr = Console.ReadLine().Split(' ');
    string[] ans = new string[n];

    for (int i = 0; i &lt; n; ++i)
    {
        ans[(i + n - d) % n] = arr[i];
    }

    for (int j = 0; j &lt; n; ++j)
    {
        Console.Write(ans[j] + " ");
    }
}
</code></pre>

<p>How to use less memory to solve this problem?</p>