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 does sksksk mean in text slang?
What is overriding in oops?
What is pointer in oop?
What are the benefits of polymorphism?
What is class encapsulation?
What is a class in oop?
How do you achieve runtime polymorphism?
What is the significance of classes in oop?
Can private class be inherited?
What is object and class in oops?
Whats oop mean?
Get me an image implementation program.
How oops is better than procedural?
Why interface is used?
How do you achieve polymorphism?