Skip to content

VILJkid/go-club-anagrams

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Club Anagram Problem

Problem Statement

You are given a slice of strings.

input = []string{string1, string2, string3, ...}

Club all the anagrams together in slice of slice of strings.

Constraints

  • Handle edge cases of input strings.

Example

input = []string{"fed", "bca", "def", "cab", "xyz"}

Slice1 = []string{"bca", "cab"}
Slice2 = []string{"def", "fed"}
Slice3 = []string{"xyz"}

output = [][]string{{"bca", "cab"},{"def", "fed"},{"xyz"}}

Solution

func ListAllAnagramsInSlice(wordList []string) [][]string

Function ListAllAnagramsInSlice solves the given problem using hashmap and iterating over each string and updating the map.
Finally, it sorts the map and returns the result as a slice of slice of strings.

Execution

Run the tests already provided.

go test -v

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages