Advertisement
LoopyMango

hehe

May 31st, 2023
689
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | Source Code | 0 0
  1. class Solution{
  2.     public:
  3.     void segregateElements(int v[],int n)
  4.     {
  5.         // Your code goes here
  6.         int ptr=0;
  7.         int temp[n];
  8.         int k=0;
  9.         for(int i =0;i<n;i++)
  10.         {
  11.           if(v[i]>=0)
  12.            {temp[k]=v[i];
  13.                k++;
  14.            }
  15.         }
  16.         for(int i =0;i<n;i++)
  17.         {
  18.           if(v[i]<0)
  19.            {temp[k]=v[i];
  20.                k++;
  21.            }
  22.         }
  23.         for(int i =0;i<n;i++)
  24.         {
  25.         v[i]=temp[i];
  26.         }
  27.     }
  28. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement