If you are satisfied with an approximation of "DISTINCT", there is a facinating probabilistic algorithm by Flajolet and Martin

https://en.wikipedia.org/wiki/Flajolet%E2%80%93Martin_algori...

which fits on 10 lines and does not require sorting. Improved versions of it are LogLog and HyperLogLog.

APPROX_COUNT_DISTINCT / APPROX_DISTINCT

https://www.sketchingbigdata.org/

Hard to make a case to engange with an AI written article even if not fully slop

So don't engage and be silent. What value is "I'm obsessed with telling everyone i hate llms" for the billionth time?