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 is purpose of inheritance?
Why do we use class in oops?
what is different between oops and c++
What is protected in oop?
Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)
Why is abstraction needed?
What is difference between inheritance and polymorphism?
Templates mean
what are the realtime excercises in C++?
What is polymorphism in oop example?
Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.
write a program that takes input in digits and display the result in words from 1 to 1000
What is an interface in oop?
What are two types of polymorphism?
What is abstraction in oop?