Find all unique char from string

Write a program to Find all non-repeated char from given string.


For example:

Input:
india

Output:
inda

Solution:

using System;
using System.Linq;

namespace CountOccureance
{
    class Program
    {
        static void Main()
        {
            Console.WriteLine("Enter string:");
            var str = Console.ReadLine();

            var ss = str.GroupBy(x => x).Select(x=>x.Key).ToArray();
            Console.WriteLine(ss);
            Console.ReadLine();
        }
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *