### Describe the enhancement requested The third item in #34475 : > Improve performance of grouping inside the segmenter (see [this discussion](https://github.com/apache/arrow/pull/34311/files#r1129570181)) Currently the algorithm has O(n^2) complexity, which is inefficient. ### Component(s) C++