[Solved] Passing vector by reference: Segmentation fault [duplicate]
You need to go from l to m when filling vector L: void merge(vector<int>& a, int l, int m, int r) { vector<int> L; vector<int> R; for (int i = l; i <= m; i++) L.push_back(a[i]); … } Otherwise L contains additional elements outside the range of interest. Then, index k steps off the end … Read more