A word puzzle app wants to show which words in words are rearrangements of each other: two words belong together when they use exactly the same letters the same number of times.
Write bucketWords(words) that returns the groups as arrays. List the groups in the order their first word appears in words, and keep the words inside each group in their original order.
Input: words = ["listen","enlist","google","silent","elgoog"] Output: [["listen","enlist","silent"],["google","elgoog"]]
listen, enlist, and silent share their letters, and so do google and elgoog.
Input: words = ["abc"] Output: [["abc"]]
A single word is a group of one.
0 <= words.length <= 10^40 <= words[i].length <= 100Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #33 Bucket Words by Their Letters. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.