Which code will take more time :
Code A:
void check1(vector<int> v)
{ for(int i=0;i<v.size();i++)
cout<<v[i];
}
Code B:
void check2(vector<int> & v)
{ for(int i=0;i<v.size();i++)
cout<<v[i];
}
Which code will take more time :
Code A:
void check1(vector<int> v)
{ for(int i=0;i<v.size();i++)
cout<<v[i];
}
Code B:
void check2(vector<int> & v)
{ for(int i=0;i<v.size();i++)
cout<<v[i];
}
Hey @mansi25 , If you look closely in the solution the only difference in the solution is that one vector is passed as a call by value and other vector is passes as call by reference .
In call by value the original vector will be entirely copied to the vector v which will take O(N) time .
In call by reference the original vector is only referenced to v vector so there is no real copying of values involved .
So more time will be taken by the first code and the second code will be time efficient compared to the first code .
Hope it helps 
Happy coding 