vector<int> output_list(n * m); initializes output_list to be size n*m and fills with 0’s. You then push_back values after that.
You have 3 options:
- 
Don’t initialize output_listto have values. Let the program reserve space on the fly as youpush_back.
- 
Don’t initialize output_listto have values, but increase its capacity usingreserve.
- 
Initialize output_listas you have, but don’tpush_backin the function. Instead, modify the values of the indexes instead of adding more.
5
solved Why is my final vector double the size it should be and have leading 0’s?