What difference does an ampersand (&) make?

Hey beautiful people out there,
I've been practicising dp these days, and i use memoization to solve problems. Many a times i've seen that whenever i pass a vector or string as an argument to a function without an amersand (&) i get a TLE or MLE, while adding an ampersand immediately removes it.
eg -

	int calc(vector<int> a)
	{
	............. (funciton definition)
	}

// TLE/MLE, WHILE

int calc(vector<int> &a)
	{
		..........
	}

This works perfectly fine. Why is it so? What difference does this ampersand makes?

Comments (2)