Given two strings like x=?hello? and y=?open?, remove any
character from string x which is also used in string y,
thus making the result x=?hll?.

Answer Posted / skybeaver

static public string StupidQuestion(string x, string y)
{
StringBuilder sb = new StringBuilder();
Hashtable ht = new Hashtable();

// just one pass through y
foreach( char c in y.ToCharArray() )
if( !ht.Contains(c) )
ht.Add(c, c)

// just one pass thru x
foreach( char c in x.ToCharArray() )
if( !ht.Contains(c) )
sb.Append(c);

return sb.ToString();
}

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does sksksk mean in text slang?

1816


What is overriding in oops?

808


What is pointer in oop?

719


What are the benefits of polymorphism?

843


What is class encapsulation?

808


What is a class in oop?

766


How do you achieve runtime polymorphism?

732


What is the significance of classes in oop?

787


Can private class be inherited?

882


What is object and class in oops?

772


Whats oop mean?

774


Get me an image implementation program.

1724


How oops is better than procedural?

811


Why interface is used?

731


How do you achieve polymorphism?

810