Hello. Complexity of filter is linear. But there are too many memory allocations in your implementation, that's why your solution is expected to be slow. Moreover, it's better to choose another strategy for finding pivot: it's easy to construct an array which will result in O(n^2).