private static int partition(int left, int right) {
        int pivot = array[right];
        int i = left;
        int j = right - 1;
        
        do{
            while(array[i] <= pivot && i < right)
                i++;
            
            while(array[j] >= pivot && j > left)
                j--;
            
            if(i < j)
                swap(i,j);
            
        }while(i < j);
        
        if(array[i] > pivot){
            swap(i ,right);
        }
        
        return i;
    }