void segregateEvenOdd(int arr[], int n) {
vector<int>v;
multiset<int>s1;
multiset<int>s2;
for(int i=0;i<n;i++)
{
if(arr[i]%2==0) s1.insert(arr[i]);
else s2.insert(arr[i]);
}
for(auto x:s1)
{
v.push_back(x);
}
for(auto x:s2)
{
v.push_back(x);
}
for(int i=0;i<n;i++)
arr[i]=v[i];
}
};
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter