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
Explain about c# language.
Can we create extension method for interface?
What is the implicit name of the parameter that gets passed into the set method/property of a class?
How long has c# been around?
List down the reason behind the usage of c# language.
What is a strong name in c#?
Difference between directcast and ctype.
What is anonymous methods in c#?
What is concrete method in c#?
What is CLR and its application.?
What is serialization in unity?
What does assert() do in c#?
What’s thread.sleep() in threading ?
What does the keyword “virtual†declare for a method or property?
What is the difference between finalize() and dispose()?