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 private class in c#?
What is the difference between class and namespace?
Is there an equivalent of exit() for quitting a c# .net application?
Are there constructors in c sharp?
What is the difference between asp net and c#?
What does an indexer do?
What is encapsulation in csharp?
How does the clr work?
What are the classes contained in a single .NET DLL ?
What is Inheritance in C#?
What is object type in c#?
What are the types of access modifiers?
Major difference between Basic httpbinding and WShttpbinding?
In languages without exception-handling facilities, we could send an error-handling procedure as a parameter to each procedure that can detect errors that must be handled. What disadvantages are there to this method?
What is the use of private constructor in c#?