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's the basic's in dot net
What is multilevel inheritance explain with example?
What is class in oop with example?
Why is abstraction used?
How do you achieve runtime polymorphism?
Write a program to sort the number with different sorts in one program ??
What is the real time example of encapsulation?
Is this job good for future? can do this job post grduate student?
What is multilevel inheritance in oop?
What is constructor in oop?
What is the purpose of enum?
Why interface is used?
What is constructor overloading in oop?
Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.
c++ program to swap the objects of two different classes