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 serialization in dot net?
What are mutable and immutable types in c#?
Explain metadata in c#.
what is inheritance and an example in vb.net and c# of when you might use it?
Why do we need to override in c#?
What is a console operator?
What is verbatim string literal in c#?
Why use a singleton instead of static methods?
Why do we need abstraction in c#?
What is predicate c#?
What is a three-tier application.
What are generics in c#.net?
How many root nodes are there in an xml document?
What is the difference between constant and readonly in c#?
What is parameters in c#?