Created
September 13, 2015 11:17
-
-
Save Lyubaev/471180dd0bc67a43a61f to your computer and use it in GitHub Desktop.
Revisions
-
Lyubaev created this gist
Sep 13, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ func removeDuplicates(elements []string) []string { // Use map to record duplicates as we find them. encountered := map[string]bool{} result := []string{} for v := range elements { if encountered[elements[v]] != true { // Record this element as an encountered element. encountered[elements[v]] = true // Append to result slice. result = append(result, elements[v]) } } return result }