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
When a Static Constructor is called in a Class?
List down the reason behind the usage of c# language.
What is icomparable in c#?
What happens when thread sleep () method is called?
What's new in c#?
Can struct inherit from class c#?
What does void do in unity?
Define clr in .net?
What is the difference between a constant and a static readonly field?
What are get and set in c#?
what is an exception in .net?
Can destructors have access modifiers?
What is the advantage of static class in c#?
explain Garbage collector’s functionality on unmanaged code
What is the purpose of dependency injection?