Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
560 B
2
Indexable
Never
static List<string> FindUniqueElements(string[] arr)
    {
        HashSet<string> allElements = new HashSet<string>();
        HashSet<string> uniqueElements = new HashSet<string>();
        
        foreach (string word in arr)
        {
            if (allElements.Contains(word))
            {
                uniqueElements.Remove(word);
            }
            else
            {
                allElements.Add(word);
                uniqueElements.Add(word);
            }
        }

        return new List<string>(uniqueElements);