When I asked, it first gave the for loop answer. I asked it the complexity, it answered, then I asked it if it could find an algorithm with lower complexity and it came up with an answer using a trie, although not the reversed words trie trick.
Better than the candidates I interview would do, and probably better than I would do, I would probably need a hint to use a trie and I haven't analyzed algorithmic complexity in a quarter of a century.
Better than the candidates I interview would do, and probably better than I would do, I would probably need a hint to use a trie and I haven't analyzed algorithmic complexity in a quarter of a century.