Time Limit Exceeded on Hackerrank
<p>I successfully solved a question on Hackerrank, and it passed all test cases but I got an error Time Limit Exceeded. I'm guessing if I optimize my code it would work,but I can't think of any way to make my code more efficient.</p>

<p>The question is:
  A left rotation operation on an array of size n shifts each of the array's elements 1 unit to the left. For example, if 2 left rotations are performed on array [1,2,3,4,5], then the array would become [3,4,5,1,2].</p>

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

<p>Can any one please guide me on how to make this code more efficient?</p>

<p>My code is:</p>

<pre><code>vector&lt;int&gt; array_left_rotation(vector&lt;int&gt; a, int n, int k) {
    for (int j = 0; j &lt; k; j++){
        a[n] = a[0];
        for (int i = 0; i &lt; n; i++){
            a[i] = a[i+1];
        }
        a[n-1] = a[n];
    }
    return a;
}
</code></pre>

<p>n is the number of elements in the array
k is the number of rotations to be performed</p>