split vector in half cpp

Solutions on MaxInterview for split vector in half cpp by the best coders in the world

showing results for - "split vector in half cpp"
Henri
15 Jun 2017
1std::vector<int> vec = {89, 15, 51, 27, 98};
2std::size_t const half_size = vec.size() / 2;
3std::vector<int> half1(vec.begin(), vec.begin() + half_size);
4std::vector<int> half2(vec.begin() + half_size, vec.end());