Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void evenOddSplit(std::vector<int>& arr) {
- for (size_t i = 1; i < arr.size(); i++) {
- int currentIndex = i - 1;
- int element = arr[i];
- if(arr[i] % 2 == 1)
- continue;
- while(currentIndex >= 0 && arr[currentIndex] % 2) {
- arr[currentIndex + 1] = arr[currentIndex];
- --currentIndex;
- }
- ++currentIndex;
- arr[currentIndex] = element;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement