public void splitSwappingIterative(int[] array) {
    if (array == null) {
      throw new IllegalArgumentException("Array passed as parameter can't be null.");
    }

    int left = 0;
    int right = array.length - 1;
    while (left < right) {
      boolean shouldChangeLeft = array[left] >= 0;
      boolean shouldChangeRight = array[right] < 0;
      if (shouldChangeLeft && shouldChangeRight) {
        swap(array, left, right);
        left++;
        right--;
      } else {
        if (!shouldChangeLeft) {
          left++;
        } else if (!shouldChangeRight) {
          right--;
        }
      }
    }
  }
The second solution for this problem is much faster than the previous one. Here, instead of using a sorting
algorithm we are going over the array from left to right using two pointers and swapping
elements if needed. The time complexity of this algorithm is O(N) where N is the
number of elements in the array. The space complexity is also O(1) because we are not using any additional
data structure here as well.
src/main/java/com/github/pedrovgs/problem8/SplitArray.java