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
What is a streamwriter in c#?
Define multicast delegate in c#?
What is main thread in c#?
what are some characteristics of an array?
What is the name of c# compiler?
What is the difference between decimal and integer?
What is difference between iqueryable and ienumerable in c#?
What is datagridview in c#?
Which function is the entry point for a DLL in MS Windows 3.1?
Is post back in c#?
What is Asynchronous call and how it can be implemented using delegates?
Can we extend sealed class in c#?
What does using system mean in c#?
What is appdomain in c#?
Does c# provide copy constructor?