Welcome to LeetCode Discuss.  Please read the FAQ to help yourself making the best use of Discuss.
Ask a Question
Back to Problem

Welcome to LeetCode Discuss.

This is a place to ask questions related to only OJ problems.

Please read the FAQ to help yourself making the best use of Discuss.

What does it mean "return all groups"? But the return result is vector<string>? How can we return all groups?

0 votes
34 views

What does it mean "return all groups"? But the return result is vector? How can we return all groups? I mean, for example, we have such vector ["dog","cat","god","tac"]. What should I return?

asked 3 days ago in Anagrams by htzfun (140 points)

1 Answer

0 votes

It means return all group of anagrams being flatten into one single list.

For the input ["dog","cat","god","tac"], it should return: ["dog","cat","god","tac"], as dog and god are one group of anagrams, and cat and tac are another group of anagrams.

I will probably change the return format to a more intuitive manner sometime in the future, such as:

[
  ["dog", "god"],
  ["cat", "tac"]
]

Until this change happens, you will have to deal with the slightly confusing way of returning a flatten list, which should not affect the algorithm itself.

answered 3 days ago by 1337c0d3r (1,910 points)
edited 3 days ago by 1337c0d3r

...