Removing k-numbers from an array using partition