why there is a compilation error ?
Error in the code
reserve dont change size, ur vector size is still 0.\
use resize in place of reserve ,or use pushback for insertion
is this the efficient way of storing integer inputs in vector (using reserve to counter the size doubling issue while using push_back)
yes…
u an directly an n size vector and then read input like u do in array.
vector<int> v(n);
for(int i=0;i<n;i++)
cin>>v[i];
```this is also efficient
1 Like
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.