#include using namespace std; // Move all negative elements to left and positives to right side of the array // Approach 1 --> Partition Algo - O(n) void shiftNegatives_A(int arr[],int size){ int j = -1,pivot=0; for(int i=0;i Two-pointer Method - O(n) void shiftNegatives_B(int arr[],int size){ int left = 0, right = size-1; while(left < right){ if(arr[left]<0 && arr[right]<0){ left++; } else if(arr[left]>0 && arr[right]>0){ right--; } else if(arr[left]>0 && arr[right]<0){ swap(arr[left],arr[right]); left++; right--; } else{ left++; right--; } } } void printArray(int arr[],int size){ for(int i=0;i