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
Can you declare a field readonly?
What is callback delegate in c#?
What is the use of static members with example using c#.net.
What is writeline in c#?
Define c# delegate?
If a.equals(b) is true then a.gethashcode & b.gethashcode must always return same hash code.
What is the difference between const and static read-only?
What is session variable in c#?
What exactly happens when we debug and build the program?
What are the extension methods in c#?
Explain the difference between abstract class and interface in .net?
What is namespace in oop?
Define satellite Assembly in .NET?
In a single .NET DLL how many classes it contains?
Is c# a strongly-typed language?