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
• What are the desirable attributes for memory managment?
What are the data types in oop?
What is property in oops?
What polymorphism means?
What is the difference between encapsulation and polymorphism?
Is react oop?
What is coupling in oops?
What is polymorphism in oop example?
What is the full form of oops?
Can private class be inherited?
Why do we need polymorphism in c#?
What is difference between polymorphism and inheritance?
What is difference between data abstraction and encapsulation?
Why is polymorphism used?
What is the fundamental idea of oop?