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
How can we sort the elements of the array in descending order?
Can hashset contain duplicates c#?
What is response redirect in c#?
Why can’t struct be used instead of class for storing entity?
Describe a Struct ?
What is type system in c#?
Is comparable a functional interface?
In object oriented programming, how would you describe encapsulation in c#?
What is Co- and Contra-Variance in C#?
What is method and function in c#?
What is serialization in dot net?
How to sign an assembly with strong name?
What are sessions in c#?
What does break do in loop?
How many bits is int32?