Re-wrote mergeAndCount(), O(n) function