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 does assert() do in c#?
What does executescalar return in c#?
Is c# substring zero based?
What is Implicit conversion in C#?
How to use session under class file of APP_Code folder?
Is c# code is unmanaged or managed code?
Is a games console a computer?
Why do we need constructors?
What is cts, clr?
Write a program to find the angle between the hours and minutes in a clock
What is the meaning of 0 in c#?
How big is int16?
Define interface class in c#?
What is check/uncheck?
Tell me the difference between call by value and call by reference.