how can i return string by vilating duplicates(inpyt like
asdfsda but output should be 2a2d2sf and 2a,2d,2s,f)
Answer Posted / hari
we can modify the previous answer to make it efficient...
check it..
string x = "asdfsdaaasasa";
string output = "";
int count = 0;
IEnumerator ie = x.GetEnumerator();
IEnumerator iee = x.GetEnumerator();
while(ie.MoveNext())
{
if (!output.Contains(ie.Current.ToString()))
{
while(iee.MoveNext())
{
if ((char)ie.Current == (char)iee.Current)
{
count++;
}
}
iee.Reset();
output = output + count + ie.Current;
count = 0;
}
}
Console.WriteLine(output);
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Is boxing an implicit conversion?
What is sealed class in c#?
How do I open the console?
What is the advantage of static class in c#?
What is meant by console programming?
List down the reason behind the usage of c# language.
What's the difference between system.string and system.text.stringbuilder classes?
What is the difference between int16 and int32 in c#?
How many parameters can a method have c#?
What are the differences between static, public and void in c#?
What is dataadapter c#?
how to prevent a class from being inherited in c#.net?
What is value c#?
What does protected internal access modifier mean?
Can you inherit multiple abstract classes in c#?