how can i return string by vilating duplicates(inpyt like
asdfsda but output should be 2a2d2sf and 2a,2d,2s,f)
Answer Posted / adityakiran
I suppose this question is intended to test the knowledge on
IEnumerator. The following piece of code may give the
required first part of the output...
string x = "asdfsdaaasasa";
string output = "";
int count = 0;
IEnumerator ie = x.GetEnumerator();
IEnumerator iee = x.GetEnumerator();
while(ie.MoveNext())
{
while(iee.MoveNext())
{
if ((char)ie.Current == (char)iee.Current)
{
count++;
}
}
iee.Reset();
if (!output.Contains(ie.Current.ToString()))
output = output + count + ie.Current;
count = 0;
}
Console.WriteLine(output);
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
Explain async and await?
What is signature c#?
Does c# support a variable number of arguments?
Is Facebook a desktop application?
What is _layout cshtml?
Is it possible to have different access modifiers on the get/set methods of a property in c#?
how to insert the data from the grid view to database table though button click.pls send the answer to mail id suri1319@gmail.com
What is instantiating a class?
How many kinds of elements an array can have?
How do I develop c# apps?
What are the variables in c#?
How do you sort an array in c#?
What is string literal in c#?
Can we override static class in c#?
Explain about c# language.