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

hi all..i want to know oops concepts clearly can any1 explain??

1757


c++ program to swap the objects of two different classes

1903


What are properties in oop?

695


write knight tour problem which is present in datastructure

2245


Hi friends I have experience of 6 months in website design and maintanence. Now i am looking for other IT jobs.. to switch platform. please post any interview you know in chennai.

1875






write a C++ program for booking using constructor and destructor.

2133


What polymorphism means?

703


What does sksksk mean in text slang?

1688


What is polymorphism in oop example?

620


class type to basic type conversion

1940


What are the advantages of polymorphism?

669


What is the point of oop?

743


What is advantage of inheritance?

777


What is inheritance and how many types of inheritance?

707


Why oops is important?

687