Removing from an array incurs O(n^2) cost, and could be mitigated with the use of a Set instead. PR Close #34331