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
How is polymorphism achieved?
What is overloading in oop?
What does no cap mean?
What is encapsulation process?
Why it is called runtime polymorphism?
What is difference between abstraction and encapsulation?
What is polymorphism in oop example?
Why is polymorphism used?
Will I be able to get a picture in D drive to the c++ program? If so, help me out?
What is the difference between encapsulation and polymorphism?
What is polymorphism in oops with example?
What is the highest level of cohesion?
What is the important feature of inheritance?
What is coupling in oop?
What is encapsulation in oop?